skip to content
Alvin Lucillo

Docker-compose commands

/ 1 min read

💻 Tech

Some of the things I learned about docker-compose.

  • docker-compose exec migrate sh - This will open a shell inside the container of the service migrate. You can then run commands inside the container like checking the logs and files. If you’re familiar with k8s, this is similar to kubectl exec.
  • docker-compose logs db - This will show the logs of the service db.
  • docker-compose up --build --remove-orphans - This will build the images and remove the containers of services that are not in the docker-compose.yml file
  • docker-compose up --force-recreate - This will force recreate the containers of the services in the docker-compose.yml file. For example, if you have a postgresql service, without the flag a stopped container will be reused. With the flag, a new container will be created.