Run a two-service app with Docker Compose
8 steps · about 2 h 40 min · Beginner
- Understand what a container is (guide, Docker, 15 min)
Separate the idea of an isolated process from a virtual machine before running anything.
- Understand images and layers (guide, Docker, 15 min)
See how an image is a read-only template so pulling and tagging make sense.
- Reach a container through a port (doc, Docker, 15 min)
Publish a container port on the host and check the mapping, the first thing that trips newcomers up.
- Override environment and command (reference, Docker, 20 min)
Use the -e, --name, -d and trailing command options to change a container at run time instead of rebuilding an image.
- See why Compose exists (guide, Docker, 20 min)
Move from a pile of docker run commands to one declarative file for a multi-container app.
- Build your first Compose app (tutorial, Docker, 40 min)
Write a compose.yaml for a web service and a data store, start it and watch the services talk by name.
- Configure services with environment variables (guide, Docker, 20 min)
Keep settings in an env file and the environment key instead of hard-coding them in images.
- Start services in the right order (guide, Docker, 15 min)
Finish with depends_on and health checks so the web app waits until the database is actually ready.