我遵循了几个关于Azure容器服务的教程,我最后一遍又一遍地遇到同样的问题。
我设法用一个简单的" hello world" -like应用程序启动一个容器。 通过SSH连接到swarm master,我确认容器正在运行。
sudo docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
50f5ff6bc553 nginx "nginx -g 'daemon ..." 19 minutes ago Up 19 minutes 0.0.0.0:80->80/tcp hello-nginx
15bec25756d6 swarm:1.1.0 "/swarm manage --r..." 40 minutes ago Up 39 minutes 0.0.0.0:2375->2375/tcp containers_swarm_1
f3ae3f6fda89 progrium/consul "/bin/start -serve..." 40 minutes ago Up 39 minutes 0.0.0.0:8300-8302->8300-8302/tcp, 0.0.0.0:8400->8400/tcp, 53/tcp, 53/udp, 0.0.0.0:8500->8500/tcp, 0.0.0.0:8301-8302->8301-8302/udp containers_consul_1
curl localhost
<!DOCTYPE html> <html> <head> <title>Welcome to nginx!</title> <style>
body {
width: 35em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
} </style> </head> <body> <h1>Welcome to nginx!</h1> <p>If you see this page, the nginx web server is successfully installed and working. Further configuration is required.</p>
<p>For online documentation and support please refer to <a href="http://nginx.org/">nginx.org</a>.<br/> Commercial support is available at <a href="http://nginx.com/">nginx.com</a>.</p>
<p><em>Thank you for using nginx.</em></p> </body> </html>
我抓住代理负载均衡器的公共IP地址,然后在端口80上点击它。
请求需要很长时间,但最终失败,因为13.80.158.161需要很长时间才能响应。
我做错了什么?
更新:
主服务器上的docker node ls返回以下错误:
Error response from daemon: This node is not a swarm manager. Use "docker swarm init" or "docker swarm join" to connect this node to swarm and try again.
这显然是问题的根源。尚未确定根本原因或修复程序。
答案 0 :(得分:1)
根据sudo docker ps -a
的输出,您似乎在主服务器上创建了docker,也许您可以通过主公共IP地址来访问它。
我按照你提供的link进行测试,这是我测试的输出:
主强>:
jason@swarm-master-E3E95783-0:~$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3d744da42d16 swarm:1.1.0 "/swarm manage --r..." About an hour ago Up About an hour 0.0.0.0:2375->2375/tcp containers_swarm_1
c63107d50414 progrium/consul "/bin/start -serve..." About an hour ago Up About an hour 0.0.0.0:8300-8302->8300-8302/tcp, 0.0.0.0:8400->8400/tcp, 53/tcp, 53/udp, 0.0.0.0:8500->8500/tcp, 0.0.0.0:8301-8302->8301-8302/udp containers_consul_1
jason@swarm-master-E3E95783-0:~$
<强>代理强>:
jason@swarm-agent-E3E95783000000:~$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
1f5b28cd76d6 nginx "nginx -g 'daemon ..." 41 minutes ago Up 41 minutes 0.0.0.0:80->80/tcp hello-nginx
jason@swarm-agent-E3E95783000000:~$
这是输出:
jason@swarm-agent-E3E95783000000:~$ curl localhost
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
body {
width: 35em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
在您的方案中,可能您可以访问您的主公共IP地址。
要访问它,我们应将端口80添加到入站规则到主负载均衡器。