Most banks are moving trading and risk applications into containers, so Docker now appears even in production support interviews. Interviewers want the fundamentals, the ability to debug a broken container, and awareness of security in a regulated environment.
Core concepts
1. What is the difference between an image and a container?
An image is a read-only template made of layers. A container is a running instance of an image with a thin writable layer on top. Many containers can run from one image.
2. Containers versus virtual machines?
Containers share the host kernel and isolate processes with namespaces and cgroups, so they start in seconds and are lightweight. VMs virtualise hardware and run a full guest OS, giving stronger isolation at higher cost.
3. CMD versus ENTRYPOINT?
ENTRYPOINT defines the executable; CMD supplies default arguments that can be overridden at docker run. Use the exec (JSON array) form so the process runs as PID 1 and receives signals for clean shutdown.
4. COPY versus ADD?
COPY copies files. ADD also extracts archives and fetches URLs, which is less predictable. Prefer COPY.
5. How does layer caching work, and how do you use it?
Each instruction creates a layer; if nothing changed, Docker reuses the cached layer. Put rarely changing steps (installing dependencies) before frequently changing ones (copying source code).
6. Volumes versus bind mounts?
Volumes are managed by Docker and portable; bind mounts map a host path directly. Data written only to the container’s writable layer is lost when the container is removed.
Write a good Dockerfile
Be ready to write or review one. A multi-stage build with a non-root user scores well:
# Build stage
FROM python:3.12-slim AS build
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir --prefix=/install -r requirements.txt
# Runtime stage
FROM python:3.12-slim
WORKDIR /app
COPY --from=build /install /usr/local
COPY src/ ./src/
RUN useradd -r -u 10001 appuser
USER appuser
EXPOSE 8080
HEALTHCHECK CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8080/health')"
ENTRYPOINT ["python", "-m", "src.server"]
- Slim or distroless base image: smaller attack surface.
- Pinned versions: reproducible builds for audit.
- Non-root user and a health check.
- A
.dockerignoreto keep secrets and.gitout of the image.
Debugging questions
7. A container exits immediately after starting. What do you do?
docker ps -a # see exit code
docker logs <container> # application error
docker inspect <container> --format '{{.State.ExitCode}} {{.State.OOMKilled}}'
docker run -it --entrypoint sh <image> # explore the image
Exit code 137 usually means it was killed (often out of memory); 1 is an application error; 127 means the command was not found.
8. The app works locally but cannot reach the database in a container. Why?
Inside a container, localhost is the container itself. Use the service name on a shared Docker network (Compose does this for you), or the correct host address. Also check firewall rules and proxy settings, which are common in bank networks.
9. How do you limit a container’s resources?
--memory and --cpus flags (or limits in Compose/Kubernetes). Without limits, one noisy container can starve others on the host.
Security in a regulated environment
- Image scanning in the CI pipeline (Trivy, Prisma Cloud, Snyk) with builds blocked on critical vulnerabilities.
- Internal registries only (Artifactory, Harbor); no pulling directly from Docker Hub in production.
- Secrets never baked into images: inject at runtime from a vault such as HashiCorp Vault or CyberArk.
- Signed images and immutable tags so what was tested is exactly what runs.
Final tips
- Practise
docker build,run,exec,logs,inspect,statsandcompose upuntil they are automatic. - Link Docker to Kubernetes: most interviewers will follow up with “how would this run in Kubernetes?”
- If you containerised something in a previous role, describe the before-and-after (deploy time, environment consistency).