The Commands

This lesson lists all the relevant Docker Compose commands with brief reminders of what each one does.

  • docker-compose up is the command to deploy a Compose app. It expects the Compose file to be called docker-compose.yml or docker-compose.yaml, but you can specify a custom filename with the -f flag. It’s common to start the app in the background with the -d flag.

  • docker-compose stop will stop all of the containers in a Compose app without deleting them from the system. The app can be easily restarted with docker-compose restart.

  • docker-compose rm will delete a stopped Compose app. It will delete containers and networks, but it will not delete volumes and images.

  • docker-compose restart will restart a Compose app that has been stopped with docker-compose stop. If you have made changes to your Compose app since stopping it, these changes will not appear in the restarted app. You will need to re-deploy the app to get the changes.

  • docker-compose ps will list each container in the Compose app. It shows the current state, the command each one is running, and network ports.

  • docker-compose down will stop and delete a running Compose app. It deletes containers and networks, but not volumes and images.

Get hands-on with 1400+ tech skills courses.