This document provides an introduction and overview of Docker and Docker Compose. It begins with background on the speaker and a history of session-based, non-session based, and container-based computing. Key benefits of containers are then outlined. The document explains the terminology used in Docker and provides examples of pulling an image, building an image, and using Docker Compose to define and run a multi-container application with services like Redis, Node, and Nginx. It also lists and briefly explains many common Docker commands.
7. TERMINOLOGY
1. Docker client: command line that can be installed on Mac OS X or Windows to control most of the Docker
workflow and talk to Docker servers
2. Docker server: Docker running in daemon mode on a Linux server. The servers starts, runs, and stops/destroys
containers.
3. Docker images: layered filesystems described via metadata that represent all the dependencies necessary to
run an application.
4. Docker repository: the library of available Docker images, can be public (Docker Hub) or private
5. Docker container: a single instance of a Linux container built from the Docker image. There can be many
containers built from a single Docker image.
6. Docker host: the underlying Linux operating system that hosts the Docker daemon
7. Docker Hub: public repository of Docker images
8. Docker Trusted Registry: private image repository
9. Docker Toolbox: specialized installer for Docker tools on Mac and Windows
10. Docker Machine: automated Docker provisioning
11. Docker Swarm: host clustering and container scheduling
12. Docker Compose: define multi-container applications
13. Docker Registry: open source Docker image distribution
14. Docker Engine: creates and runs Docker containers
8. Docker Commands
● Attach Attach local standard input, output, and error streams to a running container
● Build Build an image from a Dockerfile
● Create Create a new container
● Deploy Deploy a new stack or update an existing stack
● Images List images
● Info Display system-wide information
● Kill Kill one or more running containers
● Load Load an image from a tar archive or STDIN
● Login Log in to a Docker registry
● Logout Log out from a Docker registry
● Logs Fetch the logs of a container
● Pause Pause all processes within one or more containers
● Port List port mappings or a specific mapping for the container
● Ps List containers
● Pull Pull an image or a repository from a registry
● Push Push an image or a repository to a registry
9. Docker Commands
● Rename Rename a container
● Restart Restart one or more containers
● Rm Remove one or more containers
● Rmi Remove one or more images
● Run Run a command in a new container
● Search Search the Docker Hub for images
● Start Start one or more stopped containers
● Stats Display a live stream of container(s) resource usage statistics
● Stop Stop one or more running containers
● Tag Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
● Top Display the running processes of a container
● Unpause Unpause all processes within one or more containers
● Update Update configuration of one or more containers
● Version Show the Docker version information
● Wait Block until one or more containers stop, then print their exit codes
12. Docker file commands
● ADD Copies a file from the host system onto the container
● CMD The command that runs when the container starts
● ENTRYPOINT
● ENV Sets an environment variable in the new container
● EXPOSE Opens a port for linked containers
● FROM The base image to use in the build. This is mandatory and must be the first command in the
file.
● MAINTAINER An optional value for the maintainer of the script
● ONBUILD A command that is triggered when the image in the Dcokerfile is used as a base for another
image
● RUN Executes a command and save the result as a new layer
● USER Sets the default user within the container
● VOLUME Creates a shared volume that can be shared among containers or by the host machine
● WORKDIR Set the default working directory for the container
13. Docker Compose
The answer to these questions is Docker
Compose, “a tool for defining and running
complex applications with Docker. With
Compose, you define a multi-container
application in a single file, then spin your
application up in a single command which does
everything that needs to be done to get it
running.”
Example
1 Redis container
3 Node containers
1 Nginx container
15. Top-level keys that define a section in the configuration file such as build, deploy, depends_on, networks, and so on, are
listed with the options that support them as sub-topics. This maps to the <key>: <option>: <value> indent structure of the
Compose file.
Services
Build
Command
Volumes
Ports
Networks
Dockerfile
ARG
Docker Compose (docker-compose.yml)
16. Build Build or rebuild services
Config Validate and view the Compose file
Create Create services
Down Stop and remove containers, networks, images, and volumes
Events Receive real time events from containers
Exec Execute a command in a running container
Help Get help on a command
Images List images
Kill Kill containers
Logs View output from containers
Pause Pause services
Port Print the public port for a port binding
Ps List containers
Pull Pull service images
Push Push service images
Restart Restart services
Rm Remove stopped containers
Run Run a one-off command
Scale Set number of containers for a service
Start Start services
Stop Stop services
Top Display the running processes
Unpause Unpause services
Up Create and start containers
Docker Compose CLI