Demo: writing a multi-stage Dockerfile for Shop
On This Lesson 3 topics
This lesson is planned. The outline below lists the topics it will cover. The full lesson has not been published yet.
In this lesson
build a small, non-root Shop image. Prepares JNR-049-LAB1.
Draft outline details
Step by step
- Write the two-stage Dockerfile with a
.dockerignore. - Build with
docker build -t shop:1.0 .and compare the size with a single-stage build. - Add a non-root user and confirm with
docker exec shop whoami. - Run PostgreSQL with a volume on a shared network; run Shop against it.
- Planned mistake: the app uses
localhostfor the database and fails to connect; fix with the container namedbvia an environment variable. - Remove and recreate the database container to show the data survives.
Practice
Apply this lesson with the module's lab, exercises and quiz.
Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.