Master Docker Containers with 50 free flashcards. Study using spaced repetition and focus mode for effective learning in Programming.
Docker is an open-source platform that automates the deployment of applications inside lightweight, portable containers. Containers package an application with all its dependencies, ensuring it runs consistently across different environments.
A Docker container is a runnable instance of a Docker image. It is an isolated process that shares the host OS kernel but has its own filesystem, networking, and process space. Containers are ephemeral by default.
A Docker image is a read-only template used to create containers. It consists of layered filesystems built from a Dockerfile. Images are stored in registries and can be tagged with versions like myapp:1.0.
FROM sets the base image for subsequent instructions. It must be the first instruction in a Dockerfile (aside from ARG).
Example: FROM python:3.11-slim
You can also use FROM scratch to start with an empty image.
RUN executes a command during the image build process and commits the result as a new layer.
Example: RUN apt-get update && apt-get install -y curl
Best practice: chain commands with && to reduce layers.
COPY simply copies files/directories from the build context into the image. ADD does the same but also supports:Automatic extraction of local .tar archivesFetching files from remote URLsBest practice: prefer COPY unless you need ADD's extra features.
CMD provides default arguments that can be overridden at runtime. ENTRYPOINT sets the main executable that always runs.
When both are used, CMD supplies default arguments to ENTRYPOINT:ENTRYPOINT ["python"]CMD ["app.py"]
EXPOSE documents which ports the container listens on at runtime. It does not actually publish the port.
Example: EXPOSE 8080
To publish ports, use docker run -p 8080:8080 at runtime.
WORKDIR sets the working directory for subsequent RUN, CMD, ENTRYPOINT, COPY, and ADD instructions.
Example: WORKDIR /app
If the directory doesn't exist, it is created automatically.
ENV sets environment variables that persist in the running container.ARG defines build-time variables available only during the build.
Example:ARG VERSION=1.0ENV APP_ENV=production
LABEL adds metadata to an image as key-value pairs.
Example: LABEL maintainer="dev@example.com" version="1.0"
Labels can be inspected with docker inspect and are useful for automation and documentation.
VOLUME creates a mount point and marks it as holding externally mounted volumes.
Example: VOLUME /data
Data in volumes persists beyond the container lifecycle and is managed by Docker on the host filesystem.
Flashcards
Flip to reveal
Focus Mode
Spaced repetition
Multiple Choice
Test your knowledge
Type Answer
Active recall
Learn Mode
Multi-round mastery
Match Game
Memory challenge