Most Used docker-compose Commands

Tiempo de lectura: 2 minutos

Reading Time: 2 minutes

Here are some of the most useful and commonly used Docker Compose commands along with usage examples:

  1. docker-compose up The docker-compose up command is used to build and start the services defined in the docker-compose.yml file.
docker-compose up
  1. docker-compose down The docker-compose down command is used to stop and remove the containers, networks, and volumes created by docker-compose up.
docker-compose down
  1. docker-compose build The docker-compose build command is used to build or rebuild the services defined in the docker-compose.yml file.
docker-compose build
  1. docker-compose logs The docker-compose logs command is used to view the logs of the containers for the services defined in the docker-compose.yml file.
docker-compose logs
  1. docker-compose ps The docker-compose ps command is used to show the status of the services defined in the docker-compose.yml file.
docker-compose ps
  1. docker-compose exec The docker-compose exec command is used to execute a command in a running service.
docker-compose exec myservice ls -l
  1. docker-compose up -d The docker-compose up -d command is used to start the services defined in the docker-compose.yml file in the background.
docker-compose up -d
  1. docker-compose stop The docker-compose stop command is used to stop the containers for the services defined in the docker-compose.yml file.
docker-compose stop
  1. docker-compose restart The docker-compose restart command is used to restart the containers for the services defined in the docker-compose.yml file.
docker-compose restart
  1. docker-compose rm The docker-compose rm command is used to remove the stopped containers for the services defined in the docker-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.

Leave a Comment