# 在无法访问DockerHub的服务器上安装Discourse

**URL:** https://meta.discourse.org/t/installing-discourse-in-a-server-with-no-access-to-dockerhub/264294
**Category:** Self-hosting
**Created:** [2023年五月8日 00:57 UTC](https://meta.discourse.org/t/installing-discourse-in-a-server-with-no-access-to-dockerhub/264294 "2023-05-08T00:57:55Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![mattyoung](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mattyoung/32/170562_2.png) [@mattyoung](https://meta.discourse.org/u/mattyoung)
#### Post date: [2023年五月8日 00:57 UTC](https://meta.discourse.org/t/installing-discourse-in-a-server-with-no-access-to-dockerhub/264294/1 "2023-05-08T00:57:55Z")

</div>

@sam Sam，我的公司现在正在阻止 docker hub。我在多个环境中运行 Discourse 的 Docker，需要进行升级。当然，它失败了：

```plaintext
Error response from daemon: Get https://registry-1.docker.io/v2/: http: server gave HTTP response to HTTPS client
Error response from daemon: Get https://registry-1.docker.io/v2/: http: server gave HTTP response to HTTPS client
Unable to find image 'discourse/base:2.0.20230502-0058' locally
docker: Error response from daemon: Get https://registry-1.docker.io/v2/: http: server gave HTTP response to HTTPS client.

```

对我来说，最简单的升级方法是使用同一网络之外的另一台机器，下载最新的 discourse 基础镜像……然后以某种方式将其拉取或推送到需要升级的机器上。然后以某种方式强制 Discourse 或启动器在本地查找，而不是尝试从 Docker hub 拉取……我见过各种帖子，几乎让我觉得这可能有效，但没有明确的说明。我该如何做到这一点？

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [2023年五月8日 01:26 UTC](https://meta.discourse.org/t/installing-discourse-in-a-server-with-no-access-to-dockerhub/264294/2 "2023-05-08T01:26:06Z")

</div>

`docker save` 和 `docker load` 可以帮助你实现这一点。

---

<div class="post-metadata">

### Author: ![mattyoung](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mattyoung/32/170562_2.png) [@mattyoung](https://meta.discourse.org/u/mattyoung)
#### Post date: [2023年五月8日 01:38 UTC](https://meta.discourse.org/t/installing-discourse-in-a-server-with-no-access-to-dockerhub/264294/3 "2023-05-08T01:38:52Z")

</div>

@Falco 您能否提供一些具体的命令示例，说明如何保存和加载……例如，保存什么、保存到哪里以及加载的完整命令？

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [2023年五月8日 02:50 UTC](https://meta.discourse.org/t/installing-discourse-in-a-server-with-no-access-to-dockerhub/264294/4 "2023-05-08T02:50:43Z")

</div>

我曾多次成功地运用这个帖子的想法

> <https://stackoverflow.com/questions/23935141/how-to-copy-docker-images-from-one-host-to-another-without-using-a-repository/26226261#26226261>

我明天在电脑上时可以准备一个更具体的例子

---

<div class="post-metadata">

### Author: ![mattyoung](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mattyoung/32/170562_2.png) [@mattyoung](https://meta.discourse.org/u/mattyoung)
#### Post date: [2023年五月8日 03:04 UTC](https://meta.discourse.org/t/installing-discourse-in-a-server-with-no-access-to-dockerhub/264294/6 "2023-05-08T03:04:15Z")

</div>

@Falco - 非常感谢，我期待桌面示例……希望我理解得正确，因为我担心我的主机站点被“升级”而不仅仅是“升级”。

我有一个过时的公司 discourse docker 站点，其中包含我因公司规定等原因无法移出公司的某些信息。有 4 个不同的站点……我们称它们为：[np.falcoisgreat.com](http://np.falcoisgreat.com)、[stg.falcoisgreat.com](http://stg.falcoisgreat.com)、[tst.falcoisgreat.com](http://tst.falcoisgreat.com) 和 [www.falcoisgreat.com](http://www.falcoisgreat.com)，它们都落后于大约 4 个小版本……当启动器尝试获取最新的 Docker 基础映像时，它们已无法访问 docker hub。

因此，在现实世界的互联网自由中，我启动了一个新的带有 discourse docker 的 Ubuntu 框，只是为了下载最新的 Discourse Docker 基础映像（实际上在 [https://discourse1.codeplus.cloud](https://discourse1.codeplus.cloud)）——现在我的意图是获取新映像，不包含内容，不包含任何东西，然后使用 docker save 将其 tar 起来，然后使用 curl 或 sftp 将该 tar 文件拉到 [np.falcoisgreat.com](http://np.falcoisgreat.com)，然后使用 docker load？

我不知道具体细节，我会去查看和阅读，但我担心的是我将擦除“[np.falcoisgreat.com](http://np.falcoisgreat.com)”的当前内容和配置——我当然会进行备份，但对我来说，最好知道一种不擦除任何内容的方法。请确认此解决方案是否旨在实现我的预期？

谢谢！

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [2023年五月8日 15:46 UTC](https://meta.discourse.org/t/installing-discourse-in-a-server-with-no-access-to-dockerhub/264294/7 "2023-05-08T15:46:41Z")

</div>

Be:

- server1 拥有互联网访问权限的服务器

- server2 无法访问 DockerHub 的服务器

Do:

```bash
ssh root@server1
docker pull discourse/base:2.0.20230502-0058

# 如果 server1 可以访问 server2
docker save discourse/base:2.0.20230502-0058 | bzip2 | ssh root@server2 docker load
# 等待其完成并退出 server1
ssh root@server2
cd /var/discourse
./launcher rebuild app

# 如果 server1 无法访问 server2
docker save -o /tmp/discourse-base-image.tar discourse/base:2.0.20230502-0058
# 通过 U 盘、ftp、软盘等将文件传输到 server2
ssh root@server2
docker load -i /tmp/discourse-base-image.tar
cd /var/discourse
./launcher rebuild app

```

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [2023年五月8日 16:46 UTC](https://meta.discourse.org/t/installing-discourse-in-a-server-with-no-access-to-dockerhub/264294/8 "2023-05-08T16:46:11Z")

</div>

这很酷。我不知道那个。

唯一的技巧就是知道如何以及何时更改 `discourse/base:2.0.20230502-0058`。

我认为这只是

```plaintext
cd /var/discourse
git pull
DISCOURSE_BASE=$(grep -e ^image= $DISCOURSE_DOCKER_SRC/launcher|cut -d'\"' -f2)
docker pull $DISCOURSE_BASE

```

然后继续使用 `save` 命令。

---

<div class="post-metadata">

### Author: ![mattyoung](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mattyoung/32/170562_2.png) [@mattyoung](https://meta.discourse.org/u/mattyoung)
#### Post date: [2023年五月8日 22:18 UTC](https://meta.discourse.org/t/installing-discourse-in-a-server-with-no-access-to-dockerhub/264294/9 "2023-05-08T22:18:10Z")

</div>

感谢 @Falco，到目前为止一切顺利。两个环境已升级！

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [2023年六月7日 22:18 UTC](https://meta.discourse.org/t/installing-discourse-in-a-server-with-no-access-to-dockerhub/264294/10 "2023-06-07T22:18:33Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
