Reading Time: 2 minutes
Here are some of the most useful and commonly used Docker Compose commands along with usage examples:
docker-compose up
Thedocker-compose up
command is used to build and start the services defined in thedocker-compose.yml
file.
docker-compose up
docker-compose down
Thedocker-compose down
command is used to stop and remove the containers, networks, and volumes created bydocker-compose up
.
docker-compose down
docker-compose build
Thedocker-compose build
command is used to build or rebuild the services defined in thedocker-compose.yml
file.
docker-compose build
docker-compose logs
Thedocker-compose logs
command is used to view the logs of the containers for the services defined in thedocker-compose.yml
file.
docker-compose logs
docker-compose ps
Thedocker-compose ps
command is used to show the status of the services defined in thedocker-compose.yml
file.
docker-compose ps
docker-compose exec
Thedocker-compose exec
command is used to execute a command in a running service.
docker-compose exec myservice ls -l
docker-compose up -d
Thedocker-compose up -d
command is used to start the services defined in thedocker-compose.yml
file in the background.
docker-compose up -d
docker-compose stop
Thedocker-compose stop
command is used to stop the containers for the services defined in thedocker-compose.yml
file.
docker-compose stop
docker-compose restart
Thedocker-compose restart
command is used to restart the containers for the services defined in thedocker-compose.yml
file.
docker-compose restart
docker-compose rm
Thedocker-compose rm
command is used to remove the stopped containers for the services defined in thedocker-compose.yml
file.
docker-compose rm
These are just some of the most commonly used and useful Docker Compose commands. There are many more commands and options available in Docker Compose, and more details can be found in the official Docker Compose documentation.