Sample questions
Question 1Easy
What does a container package together?
- Only the raw source code of the app
- An app with its libraries and dependencies
- A full OS kernel together with firmware
- Physical hardware drivers for the host
Answer: B. An app with its libraries and dependencies
Explanation
Containers bundle the app with everything it needs in user space, so it runs the same across environments.
Step-by-step solution
- A container bundles the app.
- It includes the libraries and dependencies it needs in user space.
- It does not include a kernel.
Why the other options are wrong
- A. Source code alone cannot run without dependencies.
- C. Containers share the host kernel.
- D. Hardware drivers belong to the host.
Question 2Easy
Which is a key advantage of containers?
- They cannot be automated with scripts
- They always need more memory than VMs
- They each require a separate kernel
- Consistency across environments
Answer: D. Consistency across environments
Explanation
Bundling dependencies removes "works on my machine" problems between dev, test and production.
Step-by-step solution
- A container bundles the app with its dependencies.
- The same image runs in dev, test and production.
- Environments behave consistently.
Why the other options are wrong
- A. Containers are highly scriptable.
- B. Containers usually need less memory than VMs.
- C. Containers share the host kernel.
Tip: Build once, run anywhere (with the same kernel type).
Question 3Easy
What is the main purpose of a container volume?
- Exposing a container port to the internet
- Increasing the CPU speed of a container
- Persisting data beyond a container's life
- Compressing the image to save space
Answer: C. Persisting data beyond a container's life
Explanation
Volumes are managed storage mounted into containers so data survives restarts and replacement.
Step-by-step solution
- A volume is storage managed outside the container's writable layer.
- It is mounted into the container at a path.
- Data in it survives restarts and container replacement.
Why the other options are wrong
- A. Exposing ports is done with port mapping.
- B. Volumes do not change CPU speed.
- D. Volumes do not compress images.
Question 4Easy
What is the difference between a container image and a container?
- They are two names for exactly the same thing
- A container is the template and an image is the running copy
- An image is a virtual machine and a container is a disk
- An image is a template; a container is a running instance
Answer: D. An image is a template; a container is a running instance
Explanation
You build an image once and can start many containers from it.
Step-by-step solution
- An image is a read-only template.
- A container is a running instance created from it.
- One image can start many containers.
Why the other options are wrong
- A. They are different things.
- B. This reverses them.
- C. Neither is a VM or a disk.
Question 5Medium
By default, data written inside a container's writable layer:
- Is automatically backed up to the cloud
- Is lost when the container is removed
- Is shared with every other running container
- Is written permanently back into the image
Answer: B. Is lost when the container is removed
Explanation
Containers are ephemeral; persistent data should go to volumes or external storage.
Step-by-step solution
- A container has a thin writable layer on top of the image.
- When the container is removed, that layer is deleted.
- Data written there is lost.
Why the other options are wrong
- A. No automatic backup exists.
- C. Each container has its own writable layer.
- D. Images are read-only and unchanged.
Tip: Container = disposable; volume = persistent.
Question 6Medium
A container image's base image is:
- An image that has no file system
- The image that later build steps add layers on top of
- The largest image stored in the registry
- The final image deployed to production
Answer: B. The image that later build steps add layers on top of
Explanation
Every Dockerfile starts FROM a base image, such as a minimal OS or language runtime image.
Step-by-step solution
- Every Dockerfile starts with FROM.
- The image named there is the base image.
- Later steps add layers on top of it.
Why the other options are wrong
- A. Base images do have file systems.
- C. Size has nothing to do with being a base.
- D. That is the final image.
Tip: Smaller base = smaller attack surface.
Question 7Medium
What does mapping a port such as 8080:80 typically do when running a container?
- Blocks all traffic on both of these ports
- Forwards container port 8080 to host port 80
- Forwards host port 8080 to container port 80
- Opens a range of 80 ports starting at 8080
Answer: C. Forwards host port 8080 to container port 80
Explanation
The format is host_port:container_port.
Step-by-step solution
- Port mapping format is host_port:container_port.
- 8080:80 means traffic to host port 8080 goes to container port 80.
Why the other options are wrong
- A. Mapping opens a path; it does not block.
- B. This reverses the order.
- D. It maps one port, not a range.
Question 8Medium
Which Linux kernel features provide container isolation and resource limits?
- Namespaces and cgroups
- Swap and paging
- Cron and systemd timers
- Inodes and symlinks
Answer: A. Namespaces and cgroups
Explanation
- Namespaces isolate what a process can see (PIDs, network, mounts);
- cgroups limit CPU, memory and I/O.
Step-by-step solution
- Namespaces limit what a process can see: its own PIDs, network, mounts.
- cgroups limit what it can use: CPU, memory, I/O.
- Together they make a container.
Why the other options are wrong
- B. Swap and paging are memory management.
- C. Cron and systemd timers schedule jobs.
- D. Inodes and symlinks are filesystem structures.
Question 9Hard
In a Dockerfile, why is it common to copy the dependency manifest and install dependencies BEFORE copying the rest of the source code?
- To keep the dependency layer cached
- So that dependencies are installed only at runtime
- Because Docker forbids copying source code first
- To make the final image larger and therefore safer
Answer: A. To keep the dependency layer cached
Explanation
Layer caching is invalidated from the first changed step onwards, so placing rarely changing steps first speeds up rebuilds.
Step-by-step solution
- Dependencies change rarely; source code changes often.
- Copy the manifest and install dependencies first.
- Then copy the source; code changes no longer invalidate the cached dependency layer.
Why the other options are wrong
- B. Dependencies are still installed at build time.
- C. Docker allows any order.
- D. Larger images are not safer.
Question 10Hard
Why is running processes as root inside containers discouraged?
- Escapes may yield host root
- Root processes are unable to use the network
- Running as root makes the image much larger
- Containers always refuse to start as root
Answer: A. Escapes may yield host root
Explanation
Running as a non-root user follows least privilege and limits the impact of a compromise.
Step-by-step solution
- Containers share the host kernel.
- If a root process escapes the container, it may gain root on the host.
- Running as a non-root user limits the damage.
Why the other options are wrong
- B. Root processes can use the network.
- C. The user does not change image size.
- D. Containers can start as root; that is the default.
Tip: Add a USER line to your Dockerfile.
Practise all 20 questions free
The full question bank with timed practice, progress tracking and Vidya, your AI tutor. Free, no ads.
Open this topic in the app →