How to rebuild and update a container without downtime with docker-compose?

后端 未结 8 1520
春和景丽
春和景丽 2021-01-29 23:00

I enjoy a lot using docker-compose.

Eg. on my server, when I want to update my app with minor changes, I only need to git pull origin master && docker-comp

8条回答
  •  暖寄归人
    2021-01-29 23:47

    You can use Swarm. Init swarm first by docker swarm init command and use healthcheck in docker-compose.yml.

    Then run below command:

    docker stack deploy -c docker-compose.yml project_name

    instead of

    docker-compose up -d.

    When docker-compose.yml file is updated only run this command again:

    docker stack deploy -c docker-compose.yml project_name

    Docker Swarm will create new version of services and stop old version after that.

提交回复
热议问题