A Slim Python Image With a Virtualenv
Labs have no container engine, so nothing is built: your files are checked by reading them.
The image of promo-api is built on the full python:3.12 image (compilers and all, 1.1 GB), runs as root, and its logs show up minutes late.
Rewrite /home/student/projects/promo-api/Dockerfile with two stages:
build on python:3.12: creates a virtualenv in /opt/venv, copies requirements.txt before installing, and installs it into the venv with --no-cache-dir.python:3.12-slim:
/opt/venv from build and puts /opt/venv/bin first in PATH,PYTHONDONTWRITEBYTECODE=1 and PYTHONUNBUFFERED=1,/app and works there,10001,CMD ["python", "main.py"]. It installs nothing itself.About this machine
Ubuntu 24.04 with no internet access. You are student with passwordless sudo. The grader checks the final state of the machine, not the commands you typed. Values like names and ports are generated for you.
Part of Docker Fundamentals. Next step: The Build Passed, the Agent Is Missing
Teaching or writing about this? Embed this lab on your page
Your machine is ready to start
A fresh, isolated Ubuntu machine boots in a few seconds with the task already set up.
No account needed: 3 of 3 free tries left. Guest machines last 30 minutes.