Docker in practice: build cache, image layers, stop signals & container storage
Each Question puts you in a concrete Docker situation. You decide what reaches the builder, when the build cache hits, what ends up in the image, how containers stop, how ports and networks connect, where data survives, and how isolated a container is.
Questions
- Not answered. Can
COPYreach a sibling directory outside the build context? - Not answered. What happens when
.dockerignoreexcludes a file thatCOPYrequests? - Not answered. Which ignore file wins when a build has two?
- Not answered. Why does
COPY main.c /src/fail when you pipe in the Dockerfile? - Not answered. Does touching a copied file invalidate its build cache?
- Not answered. Which changes can invalidate the cache for
COPY package.json /app/? - Not answered. Why can
RUN apt-get updatereturn week-old data during a rebuild? - Not answered. Which Dockerfile order keeps dependencies cached when you edit source code?
- Not answered. What must be true of a build that uses
RUN --mount=type=cache? - Not answered. How should you pass a private registry token to one build step?
- Not answered. Does rotating a build secret invalidate the cache for the
RUNstep that uses it? - Not answered. Which build-stage files end up in the final image?
- Not answered. Which image does
docker build --target test .produce? - Not answered. Why does deleting a 200 MB archive in a later
RUNstill leave the image about 200 MB bigger? - Not answered. Where does a container's write to
/etc/app.confgo when the file came from the image? - Not answered. What happens the first time a container on OverlayFS changes one byte of a large image file?
- Not answered. Which image reference pulls the same image every time?
- Not answered. Why might
ENTRYPOINT node server.jshide Docker's stop signal from Node? - Not answered. What does
docker stopdo when the main process does not exit during its grace period? - Not answered. By default, how many seconds does Docker wait before killing an unresponsive Linux container?
- Not answered. Why would you use
docker run --init? - Not answered. What does
EXPOSE 8080do by itself? - Not answered. Where does traffic to host port 8080 go with
docker run -p 8080:80 nginx? - Not answered. Who can reach a port published with
-p 8080:80and no host IP? - Not answered. How should
webconnect todbon the same user-defined bridge? - Not answered. What does
localhostmean inside thewebcontainer? - Not answered. Do you need to publish a database port so another container on the same user-defined bridge can reach it?
- Not answered. What happens to a named volume after the container using it is removed?
- Not answered. What's in a new, empty volume when you mount it over an image directory that has files?
- Not answered. What does a default read-write bind mount over
/appdo? - Not answered. What happens to files in a Docker
tmpfsmount when the container stops? - Not answered. What happens to database files in a container's writable layer when you delete the container?
- Not answered. Which statements about default Linux container isolation are true?
- Not answered. Without resource limits, how much CPU and memory can a container use?
- Not answered. With these limits, how many megabytes of swap can the container use?
- Not answered. What does Docker's default seccomp profile do on a supported Linux host?