Cannot connect to docker swarm service task

+2 votes

I was trying to to start 3 instances of a "whoami" service called bar, that simply reports it's host's hostname and 1 instance of a Nginx service called foo, from which to exec /bin/bash and fire requests to bars via curl. However, my services exit immediately after start and won't let me execute any commands on them.

Given an existing Docker Swarm setup with 1 manager and 2 workers, on the manager node:

# docker service create --name foo --replicas 1 --network test nginx
194bw6mbgwyhmyl82zcxbyzat

# docker service create --name bar --replicas 3 --network test --publish 8000:8000 jwilder/whoami
alhz41p6usu7pbyesiiqh2hrd

# docker service ls
ID NAME REPLICAS IMAGE COMMAND
194bw6mbgwyh foo 0/1 nginx 
alhz41p6usu7 bar 0/3 jwilder/whoami

# docker service ps foo
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR
5vlgohetx4l95hm2mcggd4r6a foo.1 nginx docker-swarm-1 Running Running 5 seconds ago

# docker service ps bar
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR
f1w9dxlaqgjlscwkf6ocdrui9 bar.1 jwilder/whoami docker-swarm-2 Running Running 23 seconds ago 
7xg7p0rc8oerp0p6nvnm3l73i bar.2 jwilder/whoami docker-swarm-2 Running Running 24 seconds ago 
8m2ct4pcc8t263z1n4zmitn5y bar.3 jwilder/whoami docker-swarm-3 Running Running 25 seconds ago

And, as a result:

# docker exec -it 5vlgohetx4l95hm2mcggd4r6a /bin/bash
Error response from daemon: No such container: 5vlgohetx4l95hm2mcggd4r6a


Where am I going wrong?

Sep 26, 2018 in Docker by lina
• 8,220 points
1,604 views

1 answer to this question.

0 votes

The id that command docker service ps <service> gives is not actually a container id, but a task id. To find out the container id, run docker inspect --format="{{.Status.ContainerStatus.ContainerID}}" <task id>

answered Sep 26, 2018 by Kalgi
• 52,350 points

Related Questions In Docker

0 votes
0 answers

Worker cannot connect to docker swarm manager

I have setup the docker swarm manager ...READ MORE

Jan 25, 2019 in Docker by Hamza
• 200 points

recategorized Feb 4, 2019 by Vardhan 5,109 views
0 votes
1 answer

swarm manager does not connect to nodes docker daemons on AWS

You first need to ssh into the ...READ MORE

answered Aug 24, 2018 in Docker by Nilesh
• 7,060 points
1,821 views
+3 votes
1 answer

Docker swarm, not service not deploying to other nodes

Hi @Karenh. Try removing all the old images ...READ MORE

answered Jan 31, 2020 in Docker by Aisha
2,367 views
+2 votes
1 answer
+5 votes
7 answers

Docker swarm vs kubernetes

Swarm is easy handling while kn8 is ...READ MORE

answered Aug 27, 2018 in Docker by Mahesh Ajmeria
3,908 views
+4 votes
4 answers

How To Access a Service on Host From a Docker Container?

Adding to kalgi's answer, You can also ...READ MORE

answered Oct 16, 2018 in Docker by lina
• 8,220 points

edited Oct 16, 2018 by lina 34,105 views
0 votes
1 answer

Docker unable to connect AWS EC2 cloud

Your command is not pointing to your ...READ MORE

answered Jul 16, 2018 in Docker by Kalgi
• 52,350 points
1,511 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP