I'm trying to use docker stack deploy to deploy a local node app. I'm having a terrible time getting a good workflow.
I'm confused with the stack deploy and relationship to docker hub. I'm happy to have to build the image locally, but pushing it is a problem because my network is so slow and the image is 169MB.
My question is, if I just build the image locally, should it then be deployed by the docker stack deploy? or do I always have to publish the new image to docker hub? n.b It's published to a private repository at the moment.
Why I'm asking?
I tried doing a local docker build -t myname/myimage:latest
, then redeploy with docker stack deploy with docker-compose.yml
that references image myname/myimage:latest
- but another image keeps reappearing from 24 hours ago even if I removed it locally using docker rmi
(again and again). And then the service fails to start with errors that should be resolved in the new build.
I can only think that the container deployed by stack deploy is based on the one that's published in docker hub rather than the local image. Certainly the size of the image that keeps appearing in the docker images
matches the old image that's currently in docker hub, rather than the new one.
Perhaps I'm doing something wrong or misunderstanding how the stack deploy works?
When running Docker Engine in swarm mode, you can use docker stack deploy to deploy a complete application stack to the swarm. The deploy command accepts a stack description in the form of a Compose file. The docker stack deploy command supports any Compose file of version “3.0” or above.
The stack is configured using a docker-compose file. This is a YAML file written in a domain-specific language to specify Docker services, containers and networks. Given a compose file, it is as simple as one command to deploy the stack across an entire swarm of Docker nodes.
Docker Compose is an official tool that helps you manage your Docker containers by letting you define everything through a docker-compose. yml file. docker stack is a command that's embedded into the Docker CLI. It lets you manage a cluster of Docker containers through Docker Swarm.
You use docker-compose up to create/update your containers, networks, volumes and so on. Where Docker Stack is used in Docker Swarm (Docker's orchestration and scheduling tool) and, therefore, it has additional configuration parameters (i.e. replicas, deploy, roles) that are not needed on a single docker engine.
You should try building your local image this way:
docker build -t myimage .
and refer it as "myimage:latest" in your compose file, if you want to use the local image.
If you want to push this to the hub then tag it first
docker tag id_of_myimage my_dockerhub_username/myimage:latest
and then push it.
docker push my_dockerhub_username/myimage:latest
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With