Use the compose.yaml with web and toolbox from the previous lesson. Both services belong to one Compose project, the group of resources managed together using this configuration. Run the commands from the practice folder.
Docker Compose · Lesson 2
Compose Services
Learn to start Compose services and check their container states.
Starting the Project
If port 8080 is already in use, choose a free host port in compose.yaml. For example, the published-web container from the Docker course uses port 8080 while it is running. You can keep it running and set the Compose mapping to 127.0.0.1:8081:80 if port 8081 is available. Keep port 80 on the container side and use your chosen host port in later browser requests.
Use docker compose up -d to start the services in the background. Compose creates required project resources and uses the service settings to create or update containers.
$ docker compose up -d
You run up -d from this practice folder. Which settings determine what starts?
Reading the Service List
Use docker compose ps to inspect this project. Its service column shows the names from the YAML file. Docker also assigns each container a name, which can contain the project name.
$ docker compose ps
Look for web, toolbox, and their statuses. A running container is evidence that the program is running at the time of the check. Use a browser request to verify the web response separately.
Compose reports web as running. What further check directly confirms it returns the expected page?

The screenshot uses the original host port, 8080. If you chose a different port, look for that number on the host side of the mapping.
Checking a Stopped Service
The toolbox is temporary. If it finishes sleeping or you stop it, add -a to include stopped containers in the Compose list. The example command below stops the helper in this practice project while leaving the web service running. Start the helper again when you want to continue the course.
$ docker compose stop toolbox
$ docker compose ps -a
$ docker compose start toolbox
Where should you look for the toolbox after stopping it?
For more container and Compose practice, see Docker Command Labs.
Lesson complete
You finished Compose Services
You can now use a Compose file to start and inspect a group of services.
Start the services in the selected project.
Find the service name and current status.
Include stopped services when investigating the project.
Keep your learning progress
Create a free account to save this lesson and continue learning on any device.
Create a free account