Slim the Image, Save the Secrets
Use .dockerignore to keep junk and live secrets out of your image.
A advanced Docker challenge worth 20 points. Solve it hands-on in a real Docker environment in your browser - no local setup, no fake shells.
The Challenge
Scenario: site:v1 was built from /root/site with COPY . . — it ships a 40MB backup.tar, log files, and .env with live production secrets. Anyone who pulls the image can read them.
Tasks:
- Write a
.dockerignorein/root/siteexcludingbackup.tar,*.logand.env - Rebuild as
site:v2 site:v2must be ≥30MB smaller, contain no.env/backup.tar/ logs — and still serve the site
Commands to learn: .dockerignore, docker image inspect -f '{{.Size}}', docker run --rm <img> ls
Run check when done.