Docker Interview Questions practice questions
10 questions in 1 test. Open one to answer it on its own, or take a whole test.
Test 1
Take Test 1 ›- A Node.js service has this Dockerfile: FROM node:20 / WORKDIR /app / COPY . . / RUN npm ci / CMD ["node", "server.js"] Developers complain that changing a single line of… · Images & Build Cache
- An image is built from a Dockerfile that ends with these two instructions: ENTRYPOINT ["python", "app.py"] and CMD ["--port", "8000"] An engineer starts a container with docker… · Dockerfile Instructions
- A Go service is built with FROM golang:1.26, then COPY . . and RUN go build -o /bin/app. The resulting image is close to 1 GB because it contains the whole Go toolchain, although… · Images & Build Cache
- A Node.js API registers a SIGTERM handler that closes database connections and logs "shutting down". Its Dockerfile ends with the shell-form instruction ENTRYPOINT node… · Container Runtime
- An image ships seed files in /app/data, and the application writes its state there at runtime. You need three things: the data survives docker rm and re-creating the container… · Storage
- You start two containers on one Linux host with docker run -d --name db postgres:16 and docker run -d --name api myapi, with no --network flag. The API is configured to connect… · Networking
- A Dockerfile contains ADD vendor.tar.gz /opt/vendor/, where vendor.tar.gz sits in the build context. Following a "prefer COPY over ADD" guideline, a teammate changes it to COPY… · Dockerfile Instructions
- A repository root contains the Dockerfile, the source, a 1.5 GB node_modules directory, the .git directory, and a .env file with API keys. The Dockerfile uses COPY . ., and the… · Images & Build Cache
- A compose.yaml defines web and a PostgreSQL service db, with depends_on: [db] under web. On docker compose up, db starts first, but web often crashes at startup with "connection… · Docker Compose
- A Dockerfile starts with FROM python:3.12.4-slim. Builds run on fresh CI runners with no local image cache. Two builds of the same commit, three weeks apart, produced images with… · Images & Registries