I have setup Docker swarm on single node and have created a container on it running nginx server but i am unable to connect to nginx server on specified port. Also, i am not able to attach to container. Any help is much appreciated.
[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.
Above elinks command is unable to connect to url.
It works!!
[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
This works and connects to nginx running on port 80.
Thanks!!