Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Unable to create docker service

I’m learning docker swarm and I am trying to create the docker service after initializing the swarm . I have created 3 EC2 instances and initialised a swarm with 1 manager and 2 worker nodes. I issue the following command on the manager

docker service create –replicas 3 alpine

The prompt never returns and I can only see that the status changes frequently – ready, starting, running, pending etc.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

enter image description here

I recreated the EC2 instances and tried again but the same thing happens. Am I missing something here?

>Solution :

Quite common to miss this. Your only issue is that the alpine containers exit immediately as there are no running processes inside it. You need to keep it alive, something like this will help

docker service create --replicas 3 -dt alpine

-d: detach, make the terminal available again
-t: run the terminal process inside the container

Your service has been created. You may check the same using these commands below. Notice that you will see the ‘Shutdown’ status for the containers as they have already exited.

Docker service ls
Docker service ps service-name (from above command)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading