Bring up a minimal multi-service stack with Docker Compose, verify both services are running, validate nginx responds, inspect logs, then tear everything down cleanly and remove the working directory.
Ops ticket: Spin up a small local stack for testing using Docker Compose. Bring up nginx and redis, verify both services are running, check logs, then tear it down.
Compose is often the fastest way to reproduce a multi-service environment locally. Evidence is the service status output, a successful HTTP check, and targeted log inspection.
docker compose version
Docker Compose version v2.24.6
mkdir -p /root/compose-lab && cd /root/compose-lab
(directory ready)
cat > docker-compose.yml << 'EOF'
services:
web:
image: nginx:latest
ports:
- "8081:80"
cache:
image: redis:latest
ports:
- "6379:6379"
EOF
(docker-compose.yml created)
docker compose up -d
[+] Running 2/2
✔ Container compose-lab-web-1 Started
✔ Container compose-lab-cache-1 Started
docker compose ps
NAME IMAGE STATUS PORTS
compose-lab-web-1 nginx:latest Up 0.0.0.0:8081->80/tcp
compose-lab-cache-1 redis:latest Up 0.0.0.0:6379->6379/tcp
curl -I http://localhost:8081
HTTP/1.1 200 OK
Server: nginx/1.25.x
docker compose logs --tail 5 web
web-1 | 127.0.0.1 - - [10/Feb/2026:23:00:00 +0000] "HEAD / HTTP/1.1" 200 0 "-" "curl/7.88.1"
docker compose down
[+] Running 2/2
✔ Container compose-lab-cache-1 Removed
✔ Container compose-lab-web-1 Removed
✔ Network compose-lab_default Removed
rm -rf /root/compose-lab
(removed)
Confirm Docker is installed and the Compose v2 plugin is available. On some systems, Compose may be a separate package or not included by default.
Confirm the stack is Up in docker compose ps and the port mapping is present. If the port is already in use on the host, the web service may fail to start.
Generate traffic with curl, then re-check logs. Nginx may not emit access logs until a request is made.
Ensure the stack is down and the working directory is removed.
cd /root || true
docker compose -f /root/compose-lab/docker-compose.yml down 2>/dev/null || true
rm -rf /root/compose-lab
docker compose ps shows no running services for the project and /root/compose-lab no longer exists.
docker compose version
: Shows Docker Compose version.
docker compose up -d
: Creates and starts services in the background.
-d
: Detached mode (runs in background).
docker compose ps
: Shows service status and ports for the current project.
docker compose logs --tail <N> <service>
: Shows the last N log lines for a service.
--tail <N>
: Limits output to the last N lines.
docker compose down
: Stops and removes containers and the project network.
curl -I <url>
: Fetches HTTP response headers for a quick health check.
-I
: Requests headers only (HEAD).
cat > <file> << 'EOF'
: Creates a file using a heredoc.
'EOF'
: Prevents variable expansion while writing the file.
rm -rf <path>
: Removes a directory recursively without prompting.
-r
: Recursive removal.
-f
: Force removal, no prompts.