Docker Basics

Essential Docker system commands for beginners

Getting Started with Docker Compose

Follow these steps to practice Docker Compose commands with a sample application:

1

Download the practice files: Download Practice Files

2

Extract the files and navigate to the directory in your VS Code

3

Follow the commands below to practice Docker Compose

Build the App

docker compose build

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

docker compose up -d

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

docker compose ps

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

docker compose logs -f backend

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

docker compose down

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.