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?