If you update the image for a docker-compose config, you can restart each of the containers by running
docker-compose down docker-compose up -d
Assuming you have a directory structure like the following:
|--- docker-compose-directory |--- docker_container1 |- docker-compose.yml |--- docker_container2 |- docker-compose.yml |--- docker_container3 |- docker-compose.yml
You can write a simple script to traverse each of the directories and restart the container
#!/bin/sh if [ "$#" -eq 0 ]; then dirlist=$(find $1 -mindepth 1 -maxdepth 1 -type d) for dir in $dirlist do ( cd $dir echo $dir docker-compose down docker-compose up -d ) done else cd $1 echo $1 docker-compose down docker-compose up -d fi
Save the script as something like restart.sh in the root directory of your docker-compose directory, make the file executable, and run.
This also works if you want to restart just a single docker-compose YML.
#restart all containers $ ./restart.sh #restart a single container $ ./restart.sh docker_container1