docker swarm - 无法连接到 nginx 容器

docker swarm - unable to connect to nginx container

我在单个节点上设置了 Docker swarm 并在其上创建了一个容器 运行 nginx 服务器,但我无法连接到指定端口上的 nginx 服务器。另外,我无法连接到容器。非常感谢任何帮助。

[user@hostname yum.repos.d]$ sudo docker swarm init
[user@hostname yum.repos.d]$ sudo docker info | grep -i "swarm: active"
Swarm: active
[user@hostname yum.repos.d]$
[user@hostname yum.repos.d]$ sudo docker node ls
ID                           HOSTNAME                      STATUS  AVAILABILITY  MANAGER STATUS
xxxxxxxxxxxxxxx *            hostname.server.com           Ready   Active        Leader
[user@hostname yum.repos.d]$ sudo docker service create --name web --publish 8080:80 nginx
[user@hostname ~]$ sudo docker ps -a
[sudo] password for user: 
CONTAINER ID        IMAGE                                                                           COMMAND                  CREATED             STATUS              PORTS               NAMES
xxxxxxxxxxx        nginx@sha256:ccdb5fdf47709493f9fc5af32478c0d86b3cbee0c306e3f04a0d3e640a50ea2d   "nginx -g 'daemon ..."   About an hour ago   Up About an hour    80/tcp              web.1.
[user@hostname ~]$ elinks http://localhost:8080 //says request sent but  no response received.

以上 elinks 命令无法连接到 url。

有效!!

[user@hostname ~]$ sudo docker service ps web
ID                  NAME                IMAGE               NODE                           DESIRED STATE       CURRENT STATE           ERROR               PORTS
xxxxxxxxxxxx        web.1               httpd:latest        hostname.myserver.com   Running             Running 3 minutes ago                       
[user@hostname ~]$ 
[user@hostname ~]$ elinks http://hostname.mylabserver.com:80

这有效并连接到端口 80 上的 nginx 运行。

谢谢!!