Learn
Docker
What is Docker?
- Run applications in isolation
- Dynamically Scalable
- Changes ways of working
Virtual Machine
Virtual Machines provide the functionality to execute entire operating systems. They run on top of a Hypervisor which provides access to the computer's hardware.
Docker
Docker creates a lightweight executable package of a piece of software and provides everything you need to run it.
Isn't that what VM's do?
Docker === Colaboration
Docker was not made by a single entity. It is forged through the combination of 3 components.
- LXC (Linux Containers)
- runC (Replaces LXC in later versions of Docker)
- Aufs (The filesystem tool docker uses)
- SystemD (The primary tool to Manage containers)
How To use docker
Terminology
Term | Glossary |
---|---|
Dockerfile | A text file containing all the commands needed to build each layer of a image sequentially |
Context | The files in the same folder as your docker file |
Build | The process of building an image from a Dockerfile |
Image | An ordered collection of root filesystem changes and the execution parameters for your application |
Container | A runtime instance of a Docker Image |
Compose | A tool for defining and running multi container applications with docker |
Repository | A set of docker images |
Registry | A place to publish and share docker images |
Swarm | A cluster of one or more containers running in parallel |
DockerFile
The Dockerfile defines the docker build steps.
FROM - The base image
RUN - Run any bash commands
COPY - Copy files from System to Container
EXPOSE - Open any ports
CMD - This command is ran on container start
WORKDIR - Sets DIR for commands
# Base Image Node.js version 9.5.0
FROM node:9.5.0
# Copy source code
COPY . /app
# Set working directory
WORKDIR /app
# Install application dependencies
RUN npm Install
# Configure networking
EXPOSE 80
# Run on docker application start
CMD ['npm', 'start']
Docker Commands
docker build
-
Creates Docker Image from a Dockerfile
docker images
- List all created images
docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
- Runs specified Docker Image
docker ps
- List running containers
Docker compose
Docker Compose is a tool to define and run multi container applications
It is configured with yaml
- Define each service including
- image
- ports
- restart behaviour
- environment variables
To compose your application
-
docker-compose up -d
Docker
By Thomas Ankcorn
Docker
- 148