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

后端 未结 8 1517
春和景丽
春和景丽 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:42

    Use the --build flag to the up command, along with the -d flag to run your containers in the background:

    docker-compose up -d --build
    

    This will rebuild all images defined in your compose file, then restart any containers whose images have changed.

    -d assumes that you don't want to keep everything running in your shell foreground. This makes it act more like restart, but it's not required.

提交回复
热议问题