Notice: Due to an ongoing migration of our storage and publishing system, material requested since last month will not be uploaded for the time being, and new requests are paused. All existing notes remain available.
Which Dockerfile instruction is used to set the base image for subsequent instructions?
Not quite. Try another option.
Answer: FROM
The FROM instruction initializes a new build stage and sets the Base Image for subsequent instructions. It must be the first valid instruction in a Dockerfile.
How do you define environment variables inside a Dockerfile?
Not quite. Try another option.
Answer: ENV
The ENV instruction is used to set an environment variable to a specific value, which will be available to containers running from the resulting image.
What strategy does Docker use to share image layers and maximize storage efficiency when running containers?
Not quite. Try another option.
Answer: Copy-on-write (CoW)
Docker uses a Copy-on-write (CoW) mechanism. It shares the read-only image layers and only copies files to a writable container layer if they are modified.
Question 15 of 60 · Registries: Docker Hub · Easy
What is the name of the default public registry where Docker looks for images if no custom registry URL is provided?
Not quite. Try another option.
Answer: Docker Hub
Docker Hub is the default public registry maintained by Docker, offering a vast repository of official and community images.
Which Dockerfile instruction functions as documentation to inform users about the network ports the container will listen on at runtime?
Not quite. Try another option.
Answer: EXPOSE
The EXPOSE instruction does not actually publish the port; it functions as a type of documentation between the person who builds the image and the person who runs the container.
What is the primary difference between the COPY and ADD instructions in a Dockerfile?
Not quite. Try another option.
Answer: ADD can extract local tar files and fetch remote URLs, while COPY only copies local files.
While both copy files into the image, ADD has extra features like automatically extracting local compressed archives and downloading files from remote URLs.
Question 19 of 60 · Docker Networking: DNS inside Docker · Easy
How do containers running on the same custom user-defined bridge network resolve each other's IP addresses?
Not quite. Try another option.
Answer: By using Docker's internal DNS server with container names
Docker provides an embedded DNS server for user-defined networks, allowing containers to easily resolve each other using their container names.
In a Dockerfile, both COPY and ADD can be used to add files to an image. In which of the following scenarios is ADD specifically required over COPY?
Not quite. Try another option.
Answer: When you want to extract a local tar archive automatically into the destination directory.
While both COPY and ADD copy files, ADD has extra features such as automatically extracting local tar archives and fetching files from remote URLs. Best practices recommend using COPY unless these specific features of ADD are needed.
A Dockerfile contains ENTRYPOINT ["python", "app.py"] and CMD ["--help"]. What happens if you run the container using the command docker run my-image --port 8080?
Not quite. Try another option.
Answer: The container executes python app.py --port 8080, overriding the default CMD.
When both ENTRYPOINT and CMD are defined using the exec form, CMD acts as default arguments to ENTRYPOINT. Passing arguments at runtime (--port 8080) overrides the CMD (--help), resulting in python app.py --port 8080.
Question 23 of 60 · Build context & .dockerignore · Medium
You are building a Docker image and notice the build process is sending 2GB of data to the Docker daemon, slowing it down. The large files are in a local ./data folder that is not needed inside the image. What is the most efficient way to resolve this?
Not quite. Try another option.
Answer: Add data/ to a .dockerignore file in the build context directory.
The build context is the set of files located in the specified PATH or URL. The Docker daemon loads the entire context before building. Adding data/ to .dockerignore prevents those files from being sent to the daemon, drastically reducing build time.
Question 24 of 60 · Docker Storage: Volumes vs bind mounts, backing data on host · Medium
A developer is writing code locally and wants the changes to reflect immediately inside a running container without rebuilding the image. Which storage mechanism is most appropriate?
Not quite. Try another option.
Answer: A bind mount
Bind mounts map a specific path on the host machine directly to a path in the container. This allows local file changes made by the developer to be immediately visible inside the running container, making it ideal for live-reloading during development.
Question 25 of 60 · Port mapping between host and container · Medium
You want to run a web server container and map the host's port to the container's port . Which of the following docker run flags correctly achieves this?
Not quite. Try another option.
Answer: -p 8080:80
The -p (or --publish) flag maps host ports to container ports using the syntax host_port:container_port. Therefore, -p 8080:80 correctly maps port 8080 on the host to port 80 in the container.
Question 26 of 60 · Copy-on-write mechanism · Medium
In Docker's storage architecture, what happens when a running container needs to modify an existing file that originated from the underlying read-only image layers?
Not quite. Try another option.
Answer: The file is copied from the read-only layer into the container's writable layer before being modified.
Docker uses a Copy-on-Write (CoW) strategy. If a container needs to modify a file from an image layer, it first copies the file up to its own writable container layer and modifies the copy, leaving the original read-only layer intact.
Question 27 of 60 · Image layering · Medium
To optimize a Dockerfile and reduce the final image size, a developer changes three separate RUN instructions (e.g., apt-get update, apt-get install, rm -rf /var/lib/apt/lists/*) into a single RUN instruction chained with &&. Why does this reduce the image size?
Not quite. Try another option.
Answer: It combines the operations into a single layer, ensuring temporary files deleted in the same command don't persist in hidden lower layers.
Each RUN instruction creates a new layer. If you create a file in one layer and delete it in a subsequent layer, the file is still stored in the previous layer, taking up space. Chaining them ensures the temporary files are created and deleted within the same layer, saving space.
Question 28 of 60 · Authentication & access tokens · Medium
After successfully running docker login to authenticate with a private registry, where does Docker by default store the authentication credentials or tokens on a Linux host?
Not quite. Try another option.
Answer: ~/.docker/config.json
By default, Docker stores authentication credentials (either base64-encoded or configured to use a secure credential store) in the user's home directory under ~/.docker/config.json.
Question 29 of 60 · Host & overlay networks · Medium
Which Docker network driver is best suited for communication between standalone containers running on different Docker daemon hosts within a Swarm cluster?
Not quite. Try another option.
Answer: overlay
The overlay network driver creates a distributed network among multiple Docker daemon hosts. This network sits on top of the host-specific networks, allowing containers connected to it (including swarm service containers) to communicate securely.
Consider the following Dockerfile snippet:
dockerfile
WORKDIR /app
WORKDIR src
WORKDIR bin
RUN pwd
What will be the output of the RUN pwd command during the build process?
Not quite. Try another option.
Answer: /app/src/bin
The WORKDIR instruction can resolve relative paths. If a relative path is provided, it is appended to the path of the previous WORKDIR instruction. Thus, /app + src + bin results in /app/src/bin.
Question 31 of 60 · Inspecting images (history, layers) · Medium
You want to analyze an existing Docker image to see the exact commands that were used to build it, layer by layer, along with the size of each layer. Which command should you use?
Not quite. Try another option.
Answer: docker image history <image>
docker image history shows the layers of an image, the commands that created them, their sizes, and creation times. While docker inspect shows metadata, history specifically details the step-by-step layer construction.
Question 32 of 60 · DNS inside Docker · Medium
Two containers, web and db, are attached to the default bridge network. The web container tries to ping the db container using its name (ping db). What will happen and why?
Not quite. Try another option.
Answer: The ping fails because the default bridge network does NOT support automatic DNS resolution by container name.
Automatic DNS resolution based on container names is only available in user-defined bridge networks. On the default bridge network, containers can only communicate via IP address unless legacy --link flags are used.
Question 33 of 60 · GitHub Container Registry (GHCR) · Medium
When tagging an image to push to the GitHub Container Registry (GHCR), what is the correct prefix format required for the repository name?
Not quite. Try another option.
Answer: ghcr.io/<username>/<image>:<tag>
The GitHub Container Registry uses the domain ghcr.io. Images must be tagged with this prefix followed by the GitHub username/organization and the image name.
Question 34 of 60 · Images Tagging /versioning · Medium
You have an image with the ID a1b2c3d4 tagged as myapp:v1. You execute docker tag myapp:v1 myapp:latest. What is the result regarding the image layers and storage?
Not quite. Try another option.
Answer: A new reference (tag) is created pointing to the exact same image ID, consuming no additional storage space.
Docker tags are simply human-readable pointers to a specific image ID. Tagging an existing image creates a new alias pointing to the same image ID without duplicating the image layers or consuming extra disk space.
What is the primary difference between the ARG and ENV instructions in a Dockerfile?
Not quite. Try another option.
Answer: ARG variables are only available during the build process, whereas ENV variables persist in the final image and are available at runtime.
ARG defines a variable that users can pass at build-time to the builder with the docker build command. These are not accessible inside the running container. ENV defines environment variables that are baked into the image and exist during container runtime.
Question 36 of 60 · Docker Storage: Volumes vs bind mounts, backing data on host · Medium
You need to back up the data stored in a Docker named volume called db_data. Which of the following approaches is standard practice for backing up a Docker volume?
Not quite. Try another option.
Answer: Run a temporary container, mount db_data into it, and use tar to archive the contents to a bind-mounted host directory.
The standard backup procedure for volumes is to run a temporary container with the volume mounted (e.g., using --volumes-from), mount a host directory as a bind mount, and run a tool like tar to create an archive of the volume's contents into the host directory.
A developer includes the instruction EXPOSE 80 in their Dockerfile. What is the immediate effect of this instruction when a container is run from this image without any port mapping flags?
Not quite. Try another option.
Answer: It functions purely as documentation and does not publish the port to the host.
The EXPOSE instruction does not actually publish the port. It acts as documentation between the person who builds the image and the person who runs the container. To actually publish the port, the -p or -P flag must be used with docker run.
Question 38 of 60 · Host & overlay networks · Medium
If a container is started with the flag --network host, what happens to any port mapping instructions (like -p 8080:80) passed in the docker run command?
Not quite. Try another option.
Answer: The port mapping is ignored because the container shares the host's networking namespace.
When using the host network driver, the container does not get its own IP address and uses the host's network directly. Therefore, port mapping (-p) is redundant and ignored; if the container listens on port 80, it will be available on port 80 of the host.
Question 39 of 60 · Private registries · Medium
When setting up a private Docker registry internally, a company uses the official registry:2 Docker image. If they do not configure TLS (HTTPS), what step must client machines take to push or pull images from this registry?
Not quite. Try another option.
Answer: Configure the client's Docker daemon to trust the registry by adding it to the insecure-registries list.
Docker requires registries to be secured with TLS (HTTPS) by default. If a private registry is set up using plain HTTP, client Docker daemons must be explicitly configured to treat it as an insecure registry via daemon.json.
Question 40 of 60 · docker build process · Medium
Why is running the command docker build -t myapp:1.0 . from the root directory of a host machine (i.e., /) considered highly dangerous and inefficient?
Not quite. Try another option.
Answer: It sends the entire host filesystem to the Docker daemon as the build context.
When executing docker build ., the . specifies the current directory as the build context. If run from /, Docker will attempt to package the entire root filesystem and send it to the Docker daemon, which will cause massive performance issues and likely crash the system or daemon.
A Dockerfile contains the following two instructions: ENTRYPOINT echo "Hello" CMD ["World"]
What will be the output when a container is run from this image without any additional command-line arguments?
Not quite. Try another option.
Answer: Hello
Because ENTRYPOINT is defined in the shell form (without brackets), Docker ignores any CMD or run command line arguments. The container will run /bin/sh -c 'echo "Hello"' and simply output "Hello".
Question 42 of 60 · Docker file Core Concepts: Build context & .dockerignore · Hard
You execute docker build -t myapp . in a directory containing a 10GB file named data.bin. The .dockerignore file contains the line data.bin. The Dockerfile contains the instruction COPY . /app. Which of the following statements is true regarding the build process?
Not quite. Try another option.
Answer: The 10GB file is completely ignored by the CLI and is never sent to the Docker daemon, significantly speeding up the build context transfer.
The .dockerignore file is evaluated by the Docker CLI before the build context is sent to the Docker daemon. Any matching files are excluded from the context entirely, saving bandwidth and time.
Consider the following Dockerfile snippet:
dockerfile
VOLUME /data
RUN echo "test" > /data/test.txt
What will be the state of /data/test.txt when a container is started from the resulting image?
Not quite. Try another option.
Answer: The file will not exist in the final image's /data directory.
Once a VOLUME is declared in a Dockerfile, any subsequent RUN instructions that modify that directory make changes to a temporary volume. These changes are discarded and not committed to the resulting image layer.
Question 44 of 60 · Docker Storage: Volumes vs bind mounts · Hard
You mount an empty host directory to a container directory using a bind mount (-v /empty/host/dir:/app/data), and you mount an empty Docker volume to another container directory (-v my_empty_volume:/app/config). Both /app/data and /app/config already contain files in the underlying container image. What happens to the pre-existing files in both container directories?
Not quite. Try another option.
Answer: Files in /app/data are hidden. Files in /app/config are copied into my_empty_volume and remain visible.
When you mount an empty volume into a container directory that contains files, Docker copies the container's contents into the volume. However, bind mounts do not have this behavior; an empty bind mount will simply obscure the container's existing files.
Question 45 of 60 · Docker Networking: DNS inside Docker · Hard
Why can containers attached to a user-defined bridge network resolve each other by container name, while containers on the default bridge network cannot?
Not quite. Try another option.
Answer: The default bridge network lacks an embedded DNS server; it relies on legacy /etc/hosts mapping via the --link flag.
Docker provides a built-in DNS server for user-defined networks, enabling automatic service discovery by container name. The default bridge network does not use this DNS server and requires manual --link configurations or IP address usage.
Question 46 of 60 · Docker Storage: Copy-on-write mechanism · Hard
A container is running from an image where Layer A (bottom) has file.txt (10MB) and Layer B (top) deletes file.txt. During runtime, a process in the container creates a new file.txt (5MB). How does the Union File System handle the storage size on disk for this specific sequence?
Not quite. Try another option.
Answer: The disk uses 15MB: 10MB in Layer A and 5MB in the writable container layer.
Image layers are read-only. Layer A consumes 10MB. Layer B contains a 'whiteout' file marking file.txt as deleted (negligible size). The running container's writable layer holds the newly created 5MB file.txt. Thus, both the original 10MB and the new 5MB consume disk space.
Question 47 of 60 · Docker file Core Concepts: Image layering · Hard
Consider a Node.js application Dockerfile. Which sequence of instructions optimally utilizes Docker's layer caching to prevent reinstalling dependencies unless package.json changes?
By copying only package*.json first and running npm install, the resulting layer is cached. As long as package*.json doesn't change, Docker reuses the cached npm install layer even if the source code (COPY . .) changes.
Question 48 of 60 · Image Creation in Detail: docker build process · Hard
In a multi-stage Docker build, you have three stages: builder, tester, and the final stage. You want to copy a binary from the builder stage, but you forgot to name the stage using AS builder. The builder is the first FROM instruction. How can you validly copy the binary into the final stage?
Not quite. Try another option.
Answer: COPY --from=0 /app/bin /usr/local/bin
Docker multi-stage builds zero-index the stages. If a stage is not explicitly named using the AS keyword, you can reference it by its integer index, with the first FROM instruction being stage 0.
Question 49 of 60 · Registries: Authentication & access tokens · Hard
When a developer executes docker login to a private registry on a Linux system without configuring an external credential helper, how are the credentials stored by default?
Not quite. Try another option.
Answer: They are stored in ~/.docker/config.json as a base64 encoded string, which provides no cryptographic security.
By default, without a secure credential store (like pass, osxkeychain, or wincred), Docker stores authentication credentials in ~/.docker/config.json using base64 encoding. Base64 is not encryption and is easily decodable.
Question 50 of 60 · Image Creation in Detail: Images Tagging /versioning · Hard
What is the precise definition of a 'dangling image' in Docker, and how is it typically created?
Not quite. Try another option.
Answer: An image that has no repository name or tag (shows as <none>:<none>); created when a new image is built and overwrites an existing tag.
A dangling image is an image that is not tagged and is not referenced by any container. They commonly appear when you build a new version of an image with the same name and tag as an existing image, untagging the old one.
Question 51 of 60 · Docker Networking: Host & overlay networks · Hard
You are deploying a container on a Docker Swarm using an overlay network. You need to ensure that the data-plane traffic (payload) between containers across different nodes is encrypted. How is this achieved?
Not quite. Try another option.
Answer: By setting the --opt encrypted flag when creating the overlay network, which implements IPSec tunneling.
While Swarm encrypts control-plane traffic by default, data-plane traffic (container-to-container payload) on an overlay network is unencrypted by default. It requires the --opt encrypted flag during network creation to enable IPSec encryption.
Question 52 of 60 · Docker Networking: Port mapping between host and container · Hard
A container runs a database listening on port 5432. You start it with docker run -p 5432:5432 my-db. You notice the database is accessible from the public internet. What is the most secure way to modify the -p flag so it is only accessible from the host machine itself?
Not quite. Try another option.
Answer: -p 127.0.0.1:5432:5432
The -p flag binds to 0.0.0.0 (all interfaces) by default. To restrict access to the host machine only, you must explicitly bind it to the loopback interface using -p 127.0.0.1:<host-port>:<container-port>.
What is a primary difference between the COPY and ADD instructions regarding remote URLs and compressed archives?
Not quite. Try another option.
Answer: ADD can download from remote URLs, but will only auto-extract local tar archives. COPY only works with local files and does not extract.
ADD supports remote URLs, but contrary to common misconception, it does not auto-extract remote archives—it only auto-extracts recognized compressed formats when they are local. COPY only handles local files and never extracts them.
Question 54 of 60 · Docker file Core Concepts: Dockerfile writing · Hard
You are writing a Dockerfile and need to pass a variable that is available during the build process but should NOT persist in the final image as an environment variable to prevent leaking sensitive build tokens. Which instruction should you use?
Not quite. Try another option.
Answer: ARG
ARG defines variables that users can pass at build-time to the builder. They are not persisted in the final image's environment, unlike ENV, making them better (though still visible in history unless multi-stage is used) for temporary build variables.
Question 55 of 60 · Image Creation in Detail: Inspecting images (history, layers) · Hard
When inspecting an image with docker image history <image>, you notice several layers have <missing> listed under the IMAGE ID column. What does this indicate?
Not quite. Try another option.
Answer: The layers were built on another system and pulled locally, or were generated by BuildKit which does not assign standalone IDs to intermediate layers.
The <missing> label does not indicate corruption. It means the local Docker daemon does not have a separate image ID for those intermediate layers, typically because they were pulled as a single coalesced image or built using BuildKit.
Question 56 of 60 · Docker Storage: backing data on host · Hard
You want to mount an NFS share directly as a Docker volume. Which of the following commands correctly creates a Docker volume backed by NFS using the local driver?
Docker's default local volume driver supports mounting network filesystems like NFS directly. You pass the mount options using the --opt flags, specifying the type, options (like address), and device path.
Question 57 of 60 · Registries: GitHub Container Registry (GHCR) · Hard
A developer wants to push an image to the GitHub Container Registry (GHCR). If their GitHub username is octocat and the image is app-backend, what is the strictly correct fully qualified image tag format they must use?
Not quite. Try another option.
Answer: ghcr.io/octocat/app-backend:latest
The GitHub Container Registry uses the domain ghcr.io. The structure is ghcr.io/<namespace>/<image_name>:<tag>. (Note: docker.pkg.github.com is the legacy GitHub Packages Docker registry).
Question 58 of 60 · Docker Networking: Bridge network · Hard
A container needs to be completely isolated from the host network stack, have its own MAC address, and appear as a distinct physical device on the local network (e.g., pulling an IP directly from the physical router's DHCP). Which network driver MUST be used?
Not quite. Try another option.
Answer: macvlan
The macvlan network driver assigns a unique MAC address to each container, making it appear as a physical device on the network. This allows it to bypass the host's bridge and connect directly to the underlying physical network.
Question 59 of 60 · Docker Networking: Linking containers · Hard
In legacy Docker configurations, the --link flag was used to allow containers to communicate. What happens at the host OS level when containerA is linked to containerB using --link containerB:aliasB?
Not quite. Try another option.
Answer: Docker securely shares containerB's environment variables with containerA and adds an entry to containerA's /etc/hosts file.
The legacy --link feature statically updates the dependent container's /etc/hosts file with the target container's IP address and injects the target's environment variables into the dependent container. It does not use DNS.
Question 60 of 60 · Docker file Core Concepts: Image layering · Hard
Assume a Docker image has 5 layers. A container is spawned from this image. The application inside the container attempts to read a file located in the 3rd layer (counting from the bottom). How does the storage driver resolve this read operation?
Not quite. Try another option.
Answer: It reads directly from the 3rd layer because all image layers are continuously mounted and merged into a unified view by the Union File System.
In a Union File System, read operations pass down through the layers until the file is found. It reads directly from the read-only image layer. Copy-on-write only triggers when a file is modified, not when it is merely read.
That's unit 2
Answer a few questions and your score shows up here.
Nearly through. Did unit 2 of INT332 save you a night before the exam?
LPU Notes is free. A student pays for the servers.
Did unit 2 of INT332 save you a night before the exam?
Then you can help keep it free for the next batch. Ads cover part of the server bill;
the rest comes out of a student's own pocket: the domain, the storage, and keeping
the site up through the weeks everyone needs it at once.
The payment button didn't load. An ad blocker or a filtered network is the usual reason.
to try again.