You will read the site image's recipe and ship the edit: build a new image and a container from it.
The site:1 image was built from a recipe — the Dockerfile in ~/site. Each line is an instruction for the builder:
| Instruction | What it does during the build |
|---|---|
FROM busybox |
takes the ready-made busybox image as the base |
WORKDIR /www |
creates the /www directory and makes it current |
COPY index.html . |
copies a file from the build directory into the image |
RUN … |
runs a command inside the future image — here it writes the build time to built.txt |
CMD […] |
sets the container's start command; without its own CMD the image takes the base's one |
docker build builds the image:
-t site:2 is the new image's name. The dot at the end is the build context: the directory docker hands over to the builder in full (the [internal] load build context step in the build output). COPY sees files from it and nowhere else.
COPY works once, during the build: the file lands in the image as a copy, and every container from site:1 gets the same Site v1. docker restart restarts the process in the same container, with the same files. So an edit in ~/site reaches the site in two steps: a new image, then a new container from it.
The build output is lines numbered #1, #2…: first the service steps [internal], then the Dockerfile instructions in order — [1/4] FROM …, [2/4] WORKDIR /www. CMD does not get a step of its own: it is an image setting.
Ship the edit to the site
Build the site:2 image from ~/site and replace the web container with a new one from that image, with the same name and port 8080.
Goals · 0 of 2
- Build the site:2 image from ~/site not done yet
- Run web from the new image not done yet