Linux Labs

Containers: Docker and compose / Stage 4 of 11

Dockerfile: your own image

Not running Starting usually ~20 s
Leave the lesson

Step 1 of 7 · on a machine · 5 min

The edit did not arrive

What you will learn

  • Build an image from a Dockerfile with docker build and run a container from the new version.
  • Read image layers and build output — which steps came from the cache and which ran again.
  • Write a Dockerfile on top of a ready-made image — FROM, COPY and the start command.

The company site runs in the web container: busybox serves a page on port 8080. The container's image was built from the ~/site directory. A colleague edited index.html there — changed Site v1 to Site v2 — and restarted the container.

Repeat their check: look at the file, restart the container and open the page. On this machine docker commands go through sudo. “Start” will launch docker and the container.

Exercise · look

Restart the container after the edit

In ~/site, print index.html, restart the web container, request the page on port 8080 and print index.html inside the container.

First, predict

index.html in ~/site is already fixed. What will curl show after the container restarts?

Now start the exercise, run the command and compare your prediction with the output.

Sign in and start The machine is available after signing in
Check yourself 1 question

Where does the web container get the page it serves?

  • curl keeps nothing between runs: each time it asks the server again, and the server returned Site v1.

  • docker exec web cat /www/index.html read the file from the container's disk, and it says Site v1 too.

  • Then curl would have printed Site v2, like cat index.html in ~/site. It printed Site v1, like the file in the container's /www.

The container serves its own /www/index.html, and that file says Site v1.

Ubuntu 24.04
Loading…