我有一个在edge_web_1中运行的java servlet容器,我可以在端口8080上访问它,而我无法在edge_nginx_1上访问80或443 . 有任何想法吗?
# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
99c26fe2117e nginx:1 "nginx -g 'daemon ..." 27 minutes ago Up 27 minutes 0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp edge_nginx_1
571ef4787dbc edge_web "/tmp/entrypoint.sh" 27 minutes ago Up 27 minutes 0.0.0.0:8080->8080/tcp edge_web_1
7f0c15522a70 mongo:3 "/entrypoint.sh mo..." 58 minutes ago Up 27 minutes 27017/tcp edge_db_1
来自docker主机:
# curl localhost:8080
{"code":404,"message":"HTTP 404 Not Found"}
(json响应意味着我已经通过servlet容器,404就可以了) .
# curl localhost:80
curl: (52) Empty reply from server
我得到了相同的443.我已经尝试使用18080而不是80,以防它与特权端口有关 . 使用带有digitalocean驱动程序的docker-machine创建主机 . 容器配置了docker-compose,它在本地和虚拟机驱动程序都可以使用 .
好奇(对我来说)在virtualbox docker-machine上设置了作为docker用户运行的东西,在digitalocean上它似乎以root用户身份运行 . iptables规则也非常不同,但数字海洋规则看起来与8080不同 .
# iptables -L -n
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy DROP)
target prot opt source destination
DOCKER-ISOLATION all -- 0.0.0.0/0 0.0.0.0/0
DOCKER all -- 0.0.0.0/0 0.0.0.0/0
ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 ctstate RELATED,ESTABLISHED
ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Chain DOCKER (1 references)
target prot opt source destination
ACCEPT tcp -- 0.0.0.0/0 172.17.0.4 tcp dpt:8080
ACCEPT tcp -- 0.0.0.0/0 172.17.0.3 tcp dpt:443
ACCEPT tcp -- 0.0.0.0/0 172.17.0.3 tcp dpt:80
Chain DOCKER-ISOLATION (1 references)
target prot opt source destination
RETURN all -- 0.0.0.0/0 0.0.0.0/0
ETA:
似乎与未处理卷的digitalocean docker-machine实例有关 . 查看nginx容器,它不包含卷中的文件 . 我可以用以下方法重现它:
泊坞窗,compose.yml
nginx:
image: nginx:1
ports:
- "80:80"
volumes:
- ./testconf:/etc/nginx/conf.d
- ./testhtml:/usr/share/nginx/html
testconf / nginx.conf
server {
listen 80;
server_name _;
location / {
root /usr/share/nginx/html;
try_files $uri $uri/ @proxy;
}
}
testhtml / index.html的
<!DOCTYPE html>
<html>
<body>
<p>Hello</p>
</body>
</html>
1 回答
显然,这是预期的行为,这将在本地,虚拟盒,然后部署到DO或我猜EC2 .
对我来说,似乎有点垃圾,更不用说意外了 .
https://github.com/docker/machine/issues/3982