1/25
Vocabulary flashcards for Docker essentials.
Docker Image
A lightweight, standalone, and executable software package that includes everything needed to run a piece of software, including the code, runtime, libraries, and dependencies.
Docker Container
A runtime instance of a Docker image. It includes the application and its dependencies but runs as an isolated process on the host operating system.
Docker Image vs. Container
An image is a read-only template; a container is a running instance of that image with a writable layer on top.
Dockerfile
A text file that contains a series of instructions to build a Docker image automatically.
Docker Compose
A tool to define and manage multi-container Docker applications using a YAML file to configure application services.
Dockerfile commands
FROM, RUN, CMD, COPY, ADD, ENV, EXPOSE, WORKDIR, ENTRYPOINT
FROM instruction
Specifies the base image from which you start building your image.
RUN instruction
Executes commands in a new layer on top of the current image and commits the results.
CMD instruction
Specifies the default command to run when the container starts.
CMD vs. ENTRYPOINT
CMD provides default arguments for ENTRYPOINT or command, while ENTRYPOINT sets the executable that will run.
Docker build, docker run
Common Docker commands to build and run images
docker ps
Lists running containers
docker stop
Stops a running container
docker rm
Removes a container
docker rmi
Removes an image
docker logs
View logs of a container
Docker Networking
Allows containers to communicate with each other and with the outside world.
Default Docker Network Types
bridge (default), host, none
Bridge Network
A private internal network created by Docker to allow communication between containers on the same host.
-p flag in docker run
Exposes ports using Docker, e.g. -p hostPort:containerPort
Services section in docker-compose.yml
Defines services in Docker Compose
Volumes in Docker Compose
To persist data beyond the life of containers by mounting host directories or named volumes.
Basic Structure of docker-compose.yml
version, services, volumes, networks
docker-compose up
Starts containers using Docker Compose
docker-compose down
Stops containers using Docker Compose
docker-compose ps
View running containers in Docker Compose