Getting Started with Docker Compose
Follow these steps to practice Docker Compose commands with a sample application:
2
Extract the files and navigate to the directory in your VS Code3
Follow the commands below to practice Docker ComposeBuild the App
Builds the Docker images for services defined in your docker-compose.yml file.
Usage:
Use this command when you've made changes to your Dockerfiles or need to rebuild your images before running your application.
Run the App
Starts all services defined in your docker-compose.yml file in detached mode (background).
Note:
This will take a while. When the app runs, launch it in your browser at http://localhost:3000
List the Containers
Shows a list of containers for the current Docker Compose project with their status and port mappings.
Usage:
Use this command to check the status of your running containers, see their names, and which ports they're using.
View Container Logs
Shows the logs for the backend service with follow mode enabled.
Explanation:
- docker compose logs → Shows service logs
- -f → Follow mode (streams logs in real-time)
- backend → Service name to show logs for
Refresh the frontend page a few times, the logs should display each hit.
Stop the App
Stops and removes containers, networks, and volumes created by the Docker Compose project.
Verification:
After running this command, use docker compose ps to verify the app was removed.