Docker and CI/CD Junior interview questions and answers
75 questions for a Docker and CI/CD (Junior) interview - with correct answers, explanations and links to the docs.
Take this quiz- 1.How does a container differ from a virtual machine?
- 2.What is the difference between an image and a container?
- 3.What is a Dockerfile?
- 4.What does
FROM node:22-alpinedo in a Dockerfile? - 5.What is the difference between
RUNandCMD? - 6.How does
ENTRYPOINTrelate toCMD? - 7.Why is
COPYusually preferred overADD? - 8.What does
WORKDIR /appdo? - 9.Does
EXPOSE 3000in a Dockerfile make the port reachable from the host? - 10.What does
docker run -p 8080:3000 my-appmean? - 11.How do you see stopped containers as well as running ones?
- 12.How do you read the output of a running container?
- 13.How do you open a shell inside a running container?
- 14.Why does a container exit right after starting?
- 15.What happens to files written inside a container when you remove it?
- 16.What is the difference between a volume and a bind mount?
- 17.What is
.dockerignorefor? - 18.Why copy
package.jsonand the lockfile before the rest of the source code? - 19.What does the
latesttag mean? - 20.In
docker build -t my-app ., what is the.? - 21.What is a container registry?
- 22.What is the difference between
ARGandENV? - 23.What is Docker Compose used for?
- 24.In Compose, how does the
appservice connect to thedbservice? - 25.Does
depends_on: [db]wait until the database is ready to accept connections? - 26.What does
docker compose down -vdo in addition todown? - 27.Inside a container, what does
localhostrefer to? - 28.What does
docker stopdo? - 29.What is the difference between
docker rmanddocker rmi? - 30.Your disk is full of old Docker data. What is a common cleanup command?
- 31.How do you pass an environment variable when starting a container?
- 32.What does
--rmdo indocker run --rm my-app? - 33.What is a common gotcha with Alpine-based images?
- 34.Why shouldn't you copy a
.envfile with secrets into an image? - 35.What does
-ddo indocker run -d nginx? - 36.What do the
-itflags give you? - 37.What does
--restart unless-stoppeddo? - 38.What does a
HEALTHCHECKinstruction add to a container? - 39.What is Continuous Integration (CI)?
- 40.What is the difference between continuous delivery and continuous deployment?
- 41.What does a typical CI/CD pipeline do, in order?
- 42.Why run CI on every pull request?
- 43.Where do GitHub Actions workflow files live?
- 44.In GitHub Actions, what is the difference between a job and a step?
- 45.What does
runs-on: ubuntu-latestset? - 46.What does the step
uses: actions/checkout@v4do? - 47.What does
on: [push, pull_request]define in a workflow? - 48.How should a workflow access an API token for deployment?
- 49.Why use
npm cirather thannpm installin CI? - 50.What does caching dependencies in CI speed up?
- 51.What are workflow artifacts?
- 52.What happens by default when a step in a job fails?
- 53.How do you make a deploy job wait for the test job?
- 54.What does a build matrix do?
- 55.Which file configures GitLab CI/CD?
- 56.Why keep configuration such as database URLs in environment variables?
- 57.What is a staging environment for?
- 58.What is a rollback?
- 59.What is blue-green deployment?
- 60.What does "build once, deploy many" mean?
- 61.Why pin
FROM node:22.11-sliminstead ofFROM node? - 62.Why does image size matter?
- 63.Should the
.envfile with local secrets be committed to Git? - 64.What is a required status check?
- 65.What is a flaky test?
- 66.How can a pipeline deploy only released versions?
- 67.Which user does a container's process run as by default?
- 68.What does
docker inspect <container>show? - 69.Why can't two containers on the default bridge reach each other by name?
- 70.How do you follow logs from all services in a Compose project?
- 71.
docker run -p 5432:5432 postgresfails with "port is already allocated". Why? - 72.How are an image's layers and a container's changes stored?
- 73.How does Docker Desktop run Linux containers on macOS or Windows?
- 74.What does
docker build --no-cachedo? - 75.What does
docker compose up --buildadd toup?