Sample questions
Question 1Easy
A container image vs a container:
- An image is a template; a container is a running instance
- An image is created each time you run a container with the
--rm flag set - A container is stored in a registry; an image runs on a host
- They are two names for the same thing
Answer: A. An image is a template; a container is a running instance
Explanation
You build and push images; you run containers from them, each with its own writable layer.
Step-by-step solution
- An image is a static file with all necessary code and libraries.
- A container is the running process based on that image.
- Images are used to create containers.
- Containers can run multiple instances of an image.
- Each container has its own writable layer.
Why the other options are wrong
- B. An image is not built on each run; the
--rm flag only removes the container when it stops. - C. This swaps the two: images are stored in registries and run as containers on a host, not the reverse.
- D. They are not the same: an image is the static template, and a container is one running copy of it.
Tip: Remember: images are static, containers are dynamic.
Question 2Easy
A container stops by itself as soon as it starts. The most common reason is:
- Containers always stop after one minute unless a volume is mounted
- Its main process (PID 1) exited
- The registry went offline
- The image is too large
Answer: B. Its main process (PID 1) exited
Explanation
A container lives only as long as its main process; if the command finishes or crashes, the container exits.
Step-by-step solution
- A container lives as long as its main process.
- If PID 1 exits, the container stops.
- A common cause is a command that finishes immediately.
Why the other options are wrong
- A. There is no one-minute rule.
- C. The registry is not needed after pull.
- D. Image size does not stop it.
Tip: PID 1 exits, container stops.
Question 3Easy
docker run -p 8080:80 nginx means:
- Host port 8080 forwards to container port 80
- The container gets 8080 MB of memory
- Host port 80 forwards to container port 8080
- Nginx serves 80 requests per 8080 ms at most
Answer: A. Host port 8080 forwards to container port 80
Explanation
The -p flag is host:container.
Step-by-step solution
- -p host:container maps ports.
- 8080 is the host port.
- 80 is the container port.
Why the other options are wrong
- B. It is not memory.
- C. The order is reversed.
- D. It is not a rate limit.
Tip: host:container.
Question 4Easy
What is Docker Compose typically used for?
- Building VM images
- Scheduling containers across a production cluster of hundreds of nodes
- Scanning images for vulnerabilities
- Defining and running multi-container apps locally from one file
Answer: D. Defining and running multi-container apps locally from one file
Explanation
A compose file describes services, networks and volumes so a whole stack starts with one command.
Step-by-step solution
- Docker Compose manages multiple containers together.
- It uses a single file to define all services.
- This allows running complex apps locally easily.
- The correct answer is Defining and running multi-container apps locally from one file.
Why the other options are wrong
- A. Compose does not build VM images; it defines and runs containers from a single file.
- B. Compose runs on one host for local work and is not a cluster scheduler for hundreds of nodes.
- C. Scanning images for vulnerabilities is a job for separate security tools, not for Docker Compose.
Tip: Use Docker Compose for local app development with one command.
Question 5Medium
Which Linux kernel features give containers isolation and resource limits?
- The bootloader and swap partition, configured per container
- SELinux alone, with no other features
- Namespaces for isolation and cgroups for limits
- Systemd units and cron jobs
Answer: C. Namespaces for isolation and cgroups for limits
Explanation
Namespaces isolate PIDs, network, mounts and more; control groups cap CPU, memory and I/O.
Step-by-step solution
- Containers are processes on the host that are separated by kernel features.
- Namespaces give each container its own view of PIDs, network, mounts and more, which gives isolation.
- Control groups (cgroups) cap CPU, memory and I/O, which gives resource limits.
- The correct answer is option C, namespaces for isolation and cgroups for limits.
Why the other options are wrong
- A. The bootloader and swap partition are not container isolation or limit features.
- B. SELinux is a security policy layer; on its own it gives neither isolation nor resource limits.
- D. Systemd units and cron jobs manage services and schedules, not container isolation.
Tip: Containers = namespaces (what a process can see) + cgroups (how much it can use).
Question 6Medium
Why can a container built on an Apple Silicon (ARM) laptop fail on an x86 server?
- The registry strips ARM images during every push unless signed
- x86 servers do not support Linux namespaces
- The image's binaries target the wrong CPU architecture
- Containers cannot run on servers
Answer: C. The image's binaries target the wrong CPU architecture
Explanation
Images are architecture-specific; build multi-platform images (e.g. linux/amd64 and linux/arm64) to run on both.
Step-by-step solution
- ARM and x86 are different architectures.
- Binaries compiled for one cannot run on the other.
- The image targets the wrong CPU.
Why the other options are wrong
- A. Registries do not strip ARM images.
- B. x86 supports namespaces.
- D. Containers run on servers.
Tip: Match the CPU architecture.
Question 7Medium
Why is deploying the ':latest' tag in production risky?
- It is always the oldest image in the repository
- It is mutable, so the same tag can mean different images over time
- Registries delete latest images after a day
- Kubernetes refuses to run images tagged latest under any circumstances
Answer: B. It is mutable, so the same tag can mean different images over time
Explanation
Tags can be moved; pin a specific version tag or an immutable digest so deploys are reproducible.
Step-by-step solution
- The ':latest' tag points to the most recent image pushed to the registry.
- This tag can change over time as new images are uploaded.
- Using ':latest' means deploying a potentially different image each time.
- This makes deployments unpredictable and hard to reproduce.
- Therefore, ':latest' is mutable and not reliable for production use.
Why the other options are wrong
- A. The latest tag is not the oldest image; it points to the most recently pushed image.
- C. Registries do not delete latest images after a day; the tag stays unless someone moves it.
- D. Kubernetes does not refuse the latest tag; the risk is that the tag can point to different images over time.
Tip: Always pin exact image versions in production, never use ':latest'.
Question 8Medium
OCI (Open Container Initiative) standards matter because they:
- Replace the need for a registry
- Let images built by one tool run on other compliant runtimes
- Make containers into virtual machines
- Define the pricing of container hosting across cloud vendors
Answer: B. Let images built by one tool run on other compliant runtimes
Explanation
Standard image and runtime specs keep images portable across Docker, containerd, Podman and Kubernetes.
Step-by-step solution
- OCI standards ensure images work with different runtimes.
- Images built by one tool can run on other compliant systems.
- This portability is key for interoperability between tools.
- It allows seamless use across Docker, containerd, and Podman.
- Thus, OCI standards enable runtime compatibility.
Why the other options are wrong
- A. OCI standards do not replace registries; they define image and runtime formats that registries store.
- C. OCI standards do not turn containers into virtual machines; containers still share the host kernel.
- D. Pricing of cloud container hosting is set by vendors and is not something OCI standards define.
Tip: Remember OCI makes containers work everywhere by setting universal standards.
Question 9Hard
Running a container with --privileged is discouraged because:
- It disables networking
- It makes the container read-only
- It gives the container near-full access to the host
- It doubles the container's memory limit for every process inside it
Answer: C. It gives the container near-full access to the host
Explanation
Privileged mode lifts most isolation, so a compromise of the container can easily become a host compromise.
Step-by-step solution
- Privileged mode removes container restrictions.
- Container gains access to host hardware and processes.
- This allows full control over the host system.
- Container can modify files and settings on the host.
- Container can run any process with root privileges.
- Final answer: It gives the container near-full access to the host.
Why the other options are wrong
- A. Privileged does not disable networking; the container keeps its network but gains much wider host access.
- B. A privileged container is not made read-only; it usually gets more write access to the host, not less.
- D. Privileged mode does not double the memory limit; memory limits are set separately and stay in force.
Tip: Avoid --privileged unless absolutely necessary for security.
Question 10Hard
A container exits with code 137. What does this usually indicate?
- It was killed with SIGKILL, often by the out-of-memory killer
- The image could not be pulled
- The entrypoint file was not executable
- It completed successfully
Answer: A. It was killed with SIGKILL, often by the out-of-memory killer
Explanation
Exit codes above 128 mean 'killed by signal (code − 128)': 137 − 128 = 9, SIGKILL, commonly from hitting a memory limit.
Step-by-step solution
- Exit code 137 is above 128, meaning it was killed by a signal.
- Subtract 128 from 137 to find the signal number: 137 − 128 = 9.
- Signal 9 is SIGKILL, which often happens when memory limits are exceeded.
- SIGKILL is usually triggered by the out-of-memory killer in Linux.
- This indicates the container was killed due to running out of memory.
Why the other options are wrong
- B. An image pull failure shows as an ImagePull error, not as exit code 137 from a running container.
- C. A non-executable entrypoint fails with a permission error, not with the SIGKILL signal behind code 137.
- D. Exit code 0 means success; 137 is above 128, so it reports a signal kill, not a clean finish.
Tip: Remember: exit code 137 = SIGKILL due to out-of-memory killer.
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 →