Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"docker stack deploy": where are docker images?

I created a docker compose *.yml file where I have many services with specified image tags. Then I let docker deploy a stack for me (on my local machine) with docker stack deploy -c .\my-compose-file.yml --with-registry-auth dev and it is able to run all services. When I have docker events running simultaneously, I can see image pull messages in the log, so docker pulls missing images. But when I run docker image ls -a, the pulled images are not displayed here.

So I wondering and want to know, what live cycle do the downloaded images have (will then be removed from my drive when I do docker stack rm or not), and when not, how do I clean up such images?

like image 578
Simon Achmüller Avatar asked Feb 11 '21 10:02

Simon Achmüller


People also ask

How do I deploy a docker stack?

We can deploy a docker stack using the above file by using the docker stack deploy command, and pointing it to the file we created: This will create a stack called webapp. When running the deploy command, it will give the following output, based on the services it has created:

What is the output of the deploy command in Docker?

When running the deploy command, it will give the following output, based on the services it has created: Along with the nginx and mysql services, it has also created a default network for running the services. You can list the docker stacks with the docker stack ls command: The services making up the stack can also be listed:

What is the difference between Docker stack and docker-compose?

Note that docker stack is for deploying onto a docker swarm, whilst docker-compose can be used to deploy to standalone docker nodes. If you are using Docker Swarm to orchestrate your containers, then you should have a look at using docker stack.

What is Docker and how does it work?

We’ll talk about the commands Docker provides for handling data, and how you can use them to access image and container files. Images are what you create when you run docker build; they’re stored in a container registry like the Docker Hub, and contain all the files and code to run an app.


1 Answers

I assume you have multi-node swarm configured. In such cases, the docker image ls is running in your local machine only, while the containers from the stack are distributed across nodes. The images are pulled on the nodes that will run the container.

To get the list of the containers, you will need to go to each member of the swarm and issue the command. Easy way to do it is to use, assuming you have ssh access to the nodes with identity key:

docker node ls | cut -c 31-49 | grep -v HOSTNAME | xargs -I"SERVER" sh -c "echo SERVER; ssh SERVER /usr/local/bin/docker image ls -a"
like image 169
jordanvrtanoski Avatar answered Oct 20 '22 20:10

jordanvrtanoski