# 网站无法从浏览器访问 - docker 问题

**URL:** https://meta.discourse.org/t/site-not-accessible-from-browser-docker-problems/175264
**Category:** Support
**Created:** [2021年一月6日 13:10 UTC](https://meta.discourse.org/t/site-not-accessible-from-browser-docker-problems/175264 "2021-01-06T13:10:59Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Nacho\_Caballero](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nacho_caballero/32/130189_2.png) [@Nacho\_Caballero](https://meta.discourse.org/u/Nacho_Caballero)
#### Post date: [2021年一月6日 13:10 UTC](https://meta.discourse.org/t/site-not-accessible-from-browser-docker-problems/175264/1 "2021-01-06T13:10:59Z")

</div>

我尝试安装 Forest Admin，但它需要 `docker-compose`。

由于我没有安装它，于是我进行了安装：

```plaintext
sudo apt install docker-compose

```

但当我尝试运行时，出现了错误：

```plaintext
docker-compose up
ERROR: Couldn't connect to Docker daemon at http+docker://localhost - is it running?

If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.

```

我尝试了几种方法，其中一种建议是重启 Docker：

```plaintext
sudo systemctl restart docker
Failed to restart docker.service: Unit docker.service is masked.

```

于是我取消屏蔽并重新构建，但随后无法访问应用：

```plaintext
sudo systemctl unmask docker
Removed /etc/systemd/system/docker.service.

sudo systemctl restart docker
# 无错误

```

我已经成功重新构建镜像，并且构建过程没有报错：

```plaintext
sudo /var/discourse/launcher rebuild app

```

但当我访问该 URL 时，却无法访问。

出于绝望，我还尝试了更新 Docker 并多次重新构建镜像，但都没有成功：

```plaintext
wget -qO- https://get.docker.com/ | sh

sudo /var/discourse/launcher rebuild app

```

我已经没有其他主意了。是否还有其他可以尝试的方法？

---

<div class="post-metadata">

### Author: ![Nacho\_Caballero](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nacho_caballero/32/130189_2.png) [@Nacho\_Caballero](https://meta.discourse.org/u/Nacho_Caballero)
#### Post date: [2021年一月6日 13:15 UTC](https://meta.discourse.org/t/site-not-accessible-from-browser-docker-problems/175264/2 "2021-01-06T13:15:44Z")

</div>

我想避免从备份恢复，因为那样会丢失一些数据。但如果这是唯一的选择，最佳做法是什么？

- 恢复我最新的 Digital Ocean 备份
- 恢复我最新的 Discourse 备份

---

<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: [2021年一月6日 13:49 UTC](https://meta.discourse.org/t/site-not-accessible-from-browser-docker-problems/175264/3 "2021-01-06T13:49:57Z")

</div>

我无法判断是 Docker 出了问题，还是 Forest Admin 导致 Discourse 无法运行。Forest Admin 到底要解决什么问题？

---

<div class="post-metadata">

### Author: ![Nacho\_Caballero](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nacho_caballero/32/130189_2.png) [@Nacho\_Caballero](https://meta.discourse.org/u/Nacho_Caballero)
#### Post date: [2021年一月6日 14:01 UTC](https://meta.discourse.org/t/site-not-accessible-from-browser-docker-problems/175264/4 "2021-01-06T14:01:13Z")

</div>

谢谢，Jay。我们先暂时忘掉 Forest Admin，我已经把它移除了。还有什么其他方法可以帮助我诊断问题吗？

我很有可能是把 Docker 搞坏了。如果这有关系的话，我之前使用的是 Docker 18.09.6（构建版本 481bc77），现在使用的是 20.10.2（构建版本 2291f61）。

---

<div class="post-metadata">

### Author: ![Nacho\_Caballero](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nacho_caballero/32/130189_2.png) [@Nacho\_Caballero](https://meta.discourse.org/u/Nacho_Caballero)
#### Post date: [2021年一月6日 15:07 UTC](https://meta.discourse.org/t/site-not-accessible-from-browser-docker-problems/175264/5 "2021-01-06T15:07:09Z")

</div>

好的。原来解决方案要简单得多：我只需要重启 nginx 就行了 😅

当我尝试执行时，出现了以下错误：

```plaintext
sudo service nginx restart
Job for nginx.service failed because the control process exited with error code.
See "systemctl status nginx.service" and "journalctl -xe" for details.

```

我在日志中没有发现任何明显的问题，但重启服务器确实解决了问题：

```plaintext
sudo shutdown -r now

```

现在网站运行正常了。

---

<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: [2021年一月6日 16:55 UTC](https://meta.discourse.org/t/site-not-accessible-from-browser-docker-problems/175264/6 "2021-01-06T16:55:53Z")

</div>

你不需要 nginx。我猜当你重启时，Discourse 在 nginx 重启期间抢占了 80 端口。而且你很幸运，重启后 Discourse 比 nginx 先启动。你应该卸载或禁用 nginx（除非你将其配置为反向代理，但使用 `discourse-setup` 无法实现此配置）。

---

<div class="post-metadata">

### Author: ![Nacho\_Caballero](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nacho_caballero/32/130189_2.png) [@Nacho\_Caballero](https://meta.discourse.org/u/Nacho_Caballero)
#### Post date: [2021年一月6日 19:50 UTC](https://meta.discourse.org/t/site-not-accessible-from-browser-docker-problems/175264/7 "2021-01-06T19:50:51Z")

</div>

谢谢，Jay。我配置了 nginx 作为[反向代理](https://meta.discourse.org/t/adding-an-offline-page-when-rebuilding/45238/1)，以便在重建时显示一个友好的页面。
