【发布时间】:2020-12-04 15:06:57
【问题描述】:
我在 ubuntu 20.04 服务器上测试 docker 19.03
当我启动一个 nginx 容器时
docker run --name nginx2 -p 80:80 --rm nginx
一切正常:可以使用 Ubuntu 服务器的 ip 访问网络服务器
但是当我用 docker-compose 启动容器时
services:
nginxProxy:
container_name: nginxProxy
image: nginx:latest
ports:
- '80:80'
网络服务器没有响应
我解决了这个问题:它与netplan有关,在这里找到了解决方案https://github.com/docker/for-linux/issues/924
完成对我的设置的描述:
- 我使用包 docker.io(来自 ubuntu)安装了第一个 docker,并发现了暴露的问题。
- 我现在从头开始重新安装了我的 Ubuntu 20.04,并使用包 docker-ce(来自 docker)安装了 docker,但无法连接到任何容器。 docker0 网桥已关闭。
我的网络计划是
network:
version: 2
ethernets:
mainif:
match:
name: '*'
dhcp4: yes
我将其更改为(源中描述的,有 2 个带有 eno1 和 eno2 的 nic)
network:
version: 2
ethernets:
mainif:
match:
name: 'en*'
dhcp4: yes
现在一切正常
【问题讨论】:
-
请将
docker-compose up的输出添加到您的问题中。 -
使用默认驱动创建网络“proxynet_default”
创建nginxProxy ...完成
附加到nginxProxy
nginxProxy | /docker-entrypoint.sh:/docker-entrypoint.d/不为空,会尝试执行配置
/docker-entrypoint.sh:在 /docker-entrypoint.d/
10-listen-on-ipv6-by-default.sh:获取/etc/nginx/conf.d/default.conf的校验和
/docker-entrypoint.sh:配置完成;准备启动` -
用 docker-compose up -d 运行它
标签: docker networking docker-compose