Skip to content
Ameen Abozaid
Planned lessonJNR-049-L07

Demo: writing a multi-stage Dockerfile for Shop

  • Lesson 7 of 8
  • Junior
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

  1. Write the two-stage Dockerfile with a .dockerignore.
  2. Build with docker build -t shop:1.0 . and compare the size with a single-stage build.
  3. Add a non-root user and confirm with docker exec shop whoami.
  4. Run PostgreSQL with a volume on a shared network; run Shop against it.
  5. Planned mistake: the app uses localhost for the database and fails to connect; fix with the container name db via an environment variable.
  6. Remove and recreate the database container to show the data survives.

Practice

Apply this lesson with the module's lab, exercises and quiz.

Lab and exercises Quiz

Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.

Continue to next lesson

Type to search levels, phases, modules and lessons.