Aleks Vujic
Aleks Vujic

Reputation: 2251

Update image in service without downtime

I am running a service on Docker Swarm. This is what I did to deploy the service:

docker swarm init
docker stack deploy -c docker-compose.yml MyApplication

Content of docker-compose.yml:

version: "3"
services:
    web:
        image: myimage:1.0
        ports:
            - "9000:80"
            - "9001:443"
        deploy:
            replicas: 3
            resources:
                limits:
                    cpus: "0.5"
                    memory: 256M
                restart_policy:
                    condition: on-failure

Let't say that I update the application and build a new image myimage:2.0. What is a proper way to deploy the new version of image to the service without the downtime?

Upvotes: 5

Views: 3753

Answers (2)

Douglas Miranda
Douglas Miranda

Reputation: 341

A way to achieve this is:

I have some examples on that subject:


With this you can simply run docker stack deploy... again. If there was changes in the service, it will be updated.

Upvotes: 8

Kilian
Kilian

Reputation: 1781

you can use the command docker service update --image but it will start a new container with a implicit scale 0/1.

The downtime depends of your application.

Upvotes: 2

Related Questions