Docker Compose
Browse all articles, tutorials, and guides about Docker Compose
Posts
Forward Host Port to Docker Container
Publish container ports with -p, bind them to localhost, add a port to a container that already runs, understand ports vs expose in Compose, connect to Postgres in a container, find a container IP, and connect containers from different Compose projects.
docker compose: Always Recreate Containers from Fresh Images
Run docker compose up -d --pull always --build --force-recreate to pull newer images, rebuild local ones and replace containers instead of reusing them.
How to Use Environment Variables in Docker and Docker Compose
Pass environment variables with docker run -e and --env-file, set them in Compose with environment, env_file and .env files, learn which value wins, use defaults and required variables, set ENV and PATH in a Dockerfile, and keep secrets out of all of them.
How to Rebuild, Restart and Upgrade a Docker Compose Container
restart, up -d, up --build and --force-recreate each apply a different kind of change, and only one of them rebuilds your image. Tested on Compose 5.6: which command picks up which change, how to start only some services, wait for a healthy database, upgrade without losing data, get a shell in a crashed service, and what changed from docker-compose v1.