Search code examples
docker-swarm

container fails to start in swarm mode


I tried to start the docker service using swarm mode, but I am not able to connect to port 8080

~ $ docker service ls
ID                  NAME                MODE                REPLICAS            IMAGE                  PORTS
3tdzofpn6qo5        vigilant_wescoff    replicated          0/1                 shantanu/abc:latest   *:8080->8080/tcp

~ $ docker service ps 3tdzofpn6qo5
ID                  NAME                     IMAGE                  NODE                                          DESIRED STATE       CURRENT STATE             ERROR               PORTS
iki0t3x1oqmz        vigilant_wescoff.1       shantanuo/abc:latest   ip-172-31-4-142.ap-south-1.compute.internal   Ready               Ready 1 second ago                
z88nyixy7u10         \_ vigilant_wescoff.1   shantanu/abc:latest   ip-172-31-4-142.ap-south-1.compute.internal   Shutdown            Complete 5 minutes ago            
zf4fac2a4dlh         \_ vigilant_wescoff.1   shantanu/abc:latest   ip-172-31-4-142.ap-south-1.compute.internal   Shutdown            Complete 11 minutes ago           
zzqj4lldmxox         \_ vigilant_wescoff.1   shantanu/abc:latest   ip-172-31-6-134.ap-south-1.compute.internal   Shutdown            Complete 14 minutes ago           
z8eknet7oirq         \_ vigilant_wescoff.1   shantanu/abc:latest   ip-172-31-20-50.ap-south-1.compute.internal   Shutdown            Complete 17 minutes ago           

I used docker for aws (community version)

https://docs.docker.com/docker-for-aws/#docker-community-edition-ce-for-aws

But I guess that should not make any difference and the container should work. I have tested it using docker run command it works as expected.

In case of swarm mode, how do I know what exactly is going wrong?


Solution

    1. You can use docker events on managers to see what the orchestrator is doing (but you can't see the history).
    2. You can use docker events on workers to see what containers/networks/volumes etc. are doing (but you can't see the history).
    3. You can look at the docker service logs to see current and past container logs
    4. You can use docker container inspect to see the exit (error) code of the stopped containers in that service task list.