docker / cli

The Docker CLI
Apache License 2.0
4.83k stars 1.9k forks source link

Docker stack deploys an incorrect image #2378

Open dpenas opened 4 years ago

dpenas commented 4 years ago

When I do this in one of my servers, one of the images of the docker-compose is not correct (it is an outdated image):

docker stack deploy -c docker-compose.yml builder

But when I change its name, for example by executing the following command, then it works fine:

docker stack deploy -c docker-compose.yml whatever

I think it has to do with caching, but I've tried removing all images, all containers, swarms, services... I have even done docker system prune, but with no avail. I then decided to rename /var/lib/docker, uninstall everything from docker and install it again. By doing this I was able to finally make it work with the builder name.

I've tried the exact same thing in a different staging server from scratch (where I had no Docker beforehand) and using the first command everything goes fine, so I wonder what is going on and what I can do to fix this issue without having to uninstall docker whenever this happens.

I have saved the problematic /var/lib/docker in case it is helpful in order to find what the cause of the issue is.

Let me know if I should provide more information and thank you!

thaJeztah commented 4 years ago

docker stack deploy is designed to deploy an application to a swarm cluster. As such, it does not use your "local" images, but replies on images to be present in a registry. When deploying the stack, it will resolve the digest (immutable tag) of the given image from the registry (e.g., Docker Hub), and that version of the image will be pulled on the swarm node where the service instances are deployed.

You can use the --resolve-image=never option for local development, which disables the functionality to look up the image digest from the registry, and instead run a local image with the given name.

Note that this repository is for Docker "classic" swarm, not for "swarm services" feature built in to the docker engine (which drives the docker stack deploy). docker stack deploy is a client-side feature that uses swarm services, and is maintained in the Docker cli (https://github.com/docker/cli).

I'll transfer this issue to that repository