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,100 points
42 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
• 37,580 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 in Docker by Hamza
• 180 points

recategorized Feb 4 by Vardhan 262 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
• 6,900 points
66 views
0 votes
1 answer
0 votes
1 answer

Docker can't connect to docker daemon

The Post-installation steps for Linux documentation reveals the following ...READ MORE

answered Jul 18, 2018 in Docker by Kalgi
• 2,620 points
41 views
0 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
955 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,100 points

edited Oct 16, 2018 by lina 3,289 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
• 37,580 points
42 views