What problem does Docker primarily solve?
Environment inconsistency; it provides a standardized, portable runtime across machines.
What is Docker in one sentence?
A platform for building, shipping, and running applications consistently using containers.
How do containers differ from virtual machines?
Containers share the host OS kernel, are lightweight and start in seconds; VMs include a full OS, are heavier, and start slower.
Name the main components of Docker architecture.
Docker Client, Docker Daemon (Engine), and Registries (e.g., Docker Hub).
What command verifies Docker installation by running a test container?
docker run hello-world
What is an image vs a container?
Image: immutable blueprint; Container: running instance of an image.
Analogy for image vs container?
Image = class; Container = object instance.
What does a Dockerfile define?
Instructions on how to build a Docker image (base, files, deps, commands).
List common Dockerfile instructions.
FROM, WORKDIR, COPY, RUN, ENV, EXPOSE, USER, CMD, ENTRYPOINT.
When to use ENTRYPOINT vs CMD?
ENTRYPOINT defines the main command; CMD provides default arguments that can be overridden.
Best practice for tagging images?
Use semantic versions or commit SHAs; avoid latest in production.
How to build and tag an image named myapp:1.0?
docker build -t myapp:1.0 .
How to run an image mapping host 8080 to container 8000?
docker run -p 8080:8000 <image></image>
What does -d mean in docker run?
Detached mode (runs in background).
How to view running containers?
docker ps
How to view logs of a container?
docker logs <container_id|name> (use -f to follow, -t for timestamps).
How to exec into a running container with a shell?
docker exec -it <container> sh (or bash).</container>
Why use .dockerignore?
Reduce build context, speed up builds, and avoid copying secrets/artifacts.
How to set env vars at runtime?
docker run -e KEY=VALUE <image></image>
Does EXPOSE publish the port?
No; it documents intended ports. Use -p to publish.
Why run containers as non-root?
To reduce security risk and prevent privilege escalation.
How does build cache speed up builds?
Unchanged layers are reused; changing early layers invalidates later cached layers.
One strategy to leverage cache with Python deps?
COPY requirements.txt first, RUN pip install, then COPY source.
How to remove an image by ID?
docker rmi <image_id> (use -f to force).</image_id>
; minikube service