Guide
Docker
Beginner
Run a Compose Project
Manage two services and verify service-name networking.
Objective
Use one Compose project to run a web server and a temporary client.
Create compose.yaml
services:
web:
image: nginx:alpine
ports:
- "127.0.0.1:8093:80"
client:
image: busybox:1.37
profiles: ["tools"]
command: ["wget", "-qO-", "http://web:80"]
Start and Verify
docker compose -p docker-lab config
docker compose -p docker-lab up -d web
docker compose -p docker-lab ps
Wait until http://localhost:8093 shows nginx, then run:
docker compose -p docker-lab run --rm client
docker compose -p docker-lab logs web
The client prints the web page using the service name web. Its tools profile keeps it out of a normal project startup; explicitly targeting it with run still works.
Practice
Change the published host port and repeat the client request. Explain why the client URL remains unchanged.
Cleanup
docker compose -p docker-lab down
Continue with Docker Scripting.
Add More Questions to This Guide
Know a question that should be here? Share it and help the community!
Open Google Form