HANDS-ON TASK · 1 OF 1

Containerize a web service

Project: Containerize a web service

You're a DevOps engineer at esc bash. A developer hands you a small Python web service and asks you to containerize it properly so it can run the same way everywhere - built cleanly, cache-friendly, and not running as root.

Set up the project

Run this first. It creates /root/orders-web with the app source:

bash
curl -fsSL https://raw.githubusercontent.com/Esc-Bash/project-init-scripts/main/docker/project-1/init.sh | bash

This drops in app.py (a small web app that serves esc bash orders v1 on its root path and listens on port 8000) and a requirements.txt. Do not change these files - your job is to containerize them.

What to build

In /root/orders-web, produce:

  1. A .dockerignore that excludes at least __pycache__.
  2. A Dockerfile that:
    • builds on python:3.12-slim
    • is ordered so requirements.txt is copied and installed with pip before the rest of the source is copied with COPY . .
    • creates a non-root user and switches to it so the app does not run as root
    • runs the app by default
  3. A built image tagged orders-web:1.0.
  4. A running container named orders that publishes host port 8080 to the app's port 8000.

When it works, curl http://localhost:8080/ returns esc bash orders v1, and the container runs as a non-root user. Everything here was covered across the Dockerfile topics.

Press Submit when the service is running.

Start the lab on the right to run checks.

Pass the checks to continue
Spin up a fresh environment and practice live.
docker · fresh machine · ready in under a minute