Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does docker stack deploy work with local images

Tags:

docker

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?

like image 835
Richard G Avatar asked Apr 19 '17 07:04

Richard G


People also ask

How does docker stack deploy work?

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.

Which file format is used to deploy docker stacks?

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.

What is the difference between docker compose and docker stack?

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.

Should I use docker stack or docker compose?

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.


1 Answers

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

like image 148
Akki Avatar answered Oct 14 '22 00:10

Akki