簡體   English   中英

無法連接到Digitalocean上的docker-machine容器

[英]Can't connect to docker-machine container on digitalocean

我在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

從泊塢窗主機:

# 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,以防與特權端口有關。 主機是使用docker-machine和digitalocean驅動程序創建的。 容器使用docker-compose配置,並且都可以在本地和virtualbox驅動程序中使用。

奇怪的是(對我而言)在virtualbox docker-machine上將其設置為以docker用戶身份運行,而在digitalocean上,它似乎以root用戶身份運行。 iptables規則也大不相同,但數字海洋的規則對於80和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>

顯然,這是預期的行為,它將在本地,virtualbox上運行,然后在部署到DO或EC2時不起作用。

對我來說似乎有點垃圾,更不用說是意外的了。

https://github.com/docker/machine/issues/3982

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM