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
The problem is that restart
will restart your current containers, which is not what you want.
As an example, I just did this
docker-compose build
to build the imagesdocker-compose down
1 and docker-compose up
docker-compose restart
will NOT work heredocker-compose start
instead also does not workTo be honest, i'm not completly sure you need to do a down
first, but that should be easy to check.1 The bottomline is that you need to call up
. You will see the containers of unchanged images restarting, but for the changed image you'll see recreating
.
The advantage of this over just calling up --build
is that you can see the building-process first before you restart.
1: from the comments; down is not needed, you can just call up --build
. Down has some "down"-sides, including possible being destructive to your (volume-)data.
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.