Search test library by skills or roles
⌘ K

Adaface Sample Docker Questions

Here are some sample Docker questions from our premium questions library (10273 non-googleable questions).

Skills

🧐 Question

Medium

Docker Multistage Build Analysis
Multistage Builds
Optimization
Solve
Consider the following Dockerfile, which utilizes multistage builds. The aim is to build a lightweight, optimized image that just runs the application.
 image
The Dockerfile first defines a base image that includes Node.js and npm, then it creates an intermediate image to install the npm dependencies. Afterwards, it runs the tests in another stage and finally, creates the release image.
            
            Which of the following statements are true?
            
            A: The final image will include the test scripts.
            B: If a test fails, the final image will not be created.
            C: The node_modules directory in the final image comes from the base image.
            D: The final image will only contain the necessary application files and dependencies.
            E: If the application's source code changes, only the release stage needs to be rebuilt.

Easy

Docker Networking and Volume Mounting Interplay
Networking
Volume Mounting
Solve
You have two docker containers, X and Y. Container X is running a web service listening on port 8080, and container Y is supposed to consume this service. Both containers are created from images that don't have any special network configurations.
            
            Container X has a Dockerfile as follows:
 image
And, you build and run it with the following commands:
 image
Container Y is also running alpine with python installed, and it's supposed to read data from the `/app/data` directory and send a GET request to `http://localhost:8080` every 5 minutes. The Dockerfile for container B is:
 image
And you run it with:
 image
Assuming all the python scripts work perfectly and firewall isn't blocking any connections, you find that container Y can't access the web service of container X via `http://localhost:8080` and also it can't read the data in `/app/data` directory. What could be the potential reason(s)?
A: Y can't access X's web service because they're in different Docker networks.
            B: Y can't read the data because the volume is not shared correctly.
            C: Both A and B are correct.
            D: Both A and B are incorrect.

Medium

Dockerfile Optimization
Dockerfile
Multi-stage builds
Layer Caching
Solve
You have been asked to optimize a Dockerfile for a Python application that involves a heavy dependency installation. Here is the Dockerfile you are starting with:
 image
Given that the application's source code changes frequently but the dependencies listed in requirements.txt rarely change, how can you optimize this Dockerfile to take advantage of Docker's layer caching, reducing the build time?
A: Move the `RUN pip install` command to before the `COPY` command.
            B: Change `COPY . /app` to `COPY ./app.py /app` and move the `RUN pip install` command to before the `COPY` command.
            C: Add `RUN pip cache purge` before `RUN pip install`.
            D: Replace the base image with `python:3.8-slim`.
            E: Implement multi-stage builds.

Medium

Dockerfile Updates
Cache
Solve
Check the following Dockerfile used for a project (STAGE 1):
 image
We created an image from this Dockerfile on Dec 14 2021. A couple of weeks after Dec 14 2021, Ubuntu released new security updates to their repository. After 2 months, we modified the file (STAGE 2):
 image
Couple of weeks later, we further modified the file to add a local file ada.txt to /ada.txt (STAGE 3): (Note that ada.txt exists in /home/adaface and the dockerfile exists in /home/code folders)
 image
Pick correct statements:
            
            A: If we run “docker build .” at STAGE 2, new Ubuntu updates will be fetched because apt-get update will be run again since cache is invalidated for all lines/layers of Dockerfile when a new line is added.
            B: If we run “docker build .” at STAGE 2, new Ubuntu updates will not be fetched since cache is invalidated only for last two lines of the updated Dockerfile. Since the first two commands remain the same, cached layers are re-used skipping apt get update.
            C: To skip Cache, “docker build -no-cache .” can be used at STAGE 2. This will ensure new Ubuntu updates are picked up.
            D: Docker command “docker build .” at STAGE 3 works as expected and adds local file ada.txt to the image.
            E: Docker command “docker build .” at STAGE 3 gives an error “no such file or directory” since /home/adaface/ada.txt is not part of the Dockerfile context.

Medium

Efficient Dockerfile
Dockerfile
Solve
Review the following Dockerfiles that work on two projects (project and project2):
 image
All Docker files have the same end result:
            
            - ‘project’ is cloned from git. After running few commands, ‘project’ code is removed.
            - ‘project2’ is copied from file system and permissions to the folder is changed.
Pick the correct statements:
            
            A: File 1 is the most efficient of all.
            B: File 2 is the most efficient of all.
            C: File 3 is the most efficient of all.
            D: File 4 is the most efficient of all.
            E: Merging multiple RUN commands into a single RUN command is efficient for ‘project’ since each RUN command creates a new layer with changed files and folders. Deleting files with RUN only marks these files as deleted but does not reclaim disk space. 
            F: Copying ‘project2’ files and changing ownership in two separate commands will result in two layers since Docker duplicates all the files twice.
🧐 Question🔧 Skill

Medium

Docker Multistage Build Analysis
Multistage Builds
Optimization

3 mins

Docker
Solve

Easy

Docker Networking and Volume Mounting Interplay
Networking
Volume Mounting

3 mins

Docker
Solve

Medium

Dockerfile Optimization
Dockerfile
Multi-stage builds
Layer Caching

2 mins

Docker
Solve

Medium

Dockerfile Updates
Cache

2 mins

Docker
Solve

Medium

Efficient Dockerfile
Dockerfile

2 mins

Docker
Solve
🧐 Question🔧 Skill💪 Difficulty⌛ Time
Docker Multistage Build Analysis
Multistage Builds
Optimization
Docker
Medium3 mins
Solve
Docker Networking and Volume Mounting Interplay
Networking
Volume Mounting
Docker
Easy3 mins
Solve
Dockerfile Optimization
Dockerfile
Multi-stage builds
Layer Caching
Docker
Medium2 mins
Solve
Dockerfile Updates
Cache
Docker
Medium2 mins
Solve
Efficient Dockerfile
Dockerfile
Docker
Medium2 mins
Solve

Trusted by recruitment teams in enterprises globally

Amazon Morgan Stanley Vodafone United Nations HCL PayPal Bosch WeWork Optimum Solutions Deloitte Microsoft NCS Doubtnut Sokrati J&T Express Capegemini

We evaluated several of their competitors and found Adaface to be the most compelling. Great library of questions that are designed to test for fit rather than memorization of algorithms.


Swayam Narain, CTO, Affable

hashtag image heart icon Swayam
customers across world
Join 1200+ companies in 75+ countries.
Try the most candidate friendly skills assessment tool today.
g2 badges
Ready to streamline your recruitment efforts with Adaface?
Ready to streamline your recruitment efforts with Adaface?
logo
40 min tests.
No trick questions.
Accurate shortlisting.
ada
Ada
● Online
Previous
Score: NA
Next
✖️