Docker is a platform for running and deploying your applications in isolated containers.
A container packages your app and its dependencies into a standardized unit that can be easily deployed across different environments.
The main advantage of "containerization" is that apps can be deployed more easily and with less overhead than a traditional virtual machine (VM).
Docker is based on a client-server architecture. Clients communicate with a Docker daemon process via a REST API.
The Docker daemon (server) can live on the same system as the client or remote.
The client runs commands like docker build and docker pull to communicate with the daemon.
The daemon communicates with the client to generate containers off of images defined through a Dockerfile.
The daemon also communicates with a registry to publish new images and retrieve existing images for spinning up containers.
A container is the runtime instance of an image.
A container is like a VM in that it's an isolated environment having it's own operating system and processes.
A container is unlike a VM in that it shares the same kernal with it's host. This means a Docker container doesn't require a hypervisor and the costly overhead of spinning up a separate VM.
A Docker image provides instructions for creating a container. It represents the "blueprint" for a container.
A Dockerfile provides instructions for creating an image. It defines what goes on in the environment inside a given container...
# Use an official Python runtime as a parent image FROM python:2.7-slim # Set the working directory to /app WORKDIR /app # Copy the current directory contents into the container at /app ADD . /app # Install any needed packages specified in requirements.txt RUN pip install --trusted-host pypi.python.org -r requirements.txt # Make port 80 available to the world outside this container EXPOSE 80 # Define environment variable ENV NAME World # Run app.py when the container launches CMD ["python", "app.py"] Dockerfile (END)
This sample is from the official documentation. Notice how it defines environment variables and processes to run for generating an image.
A registry is a collection of repositories. A repository is a collection of images.
Similar to the npm registry, you can publish images to a central Docker registry. You can also create private registries for publishing images.
Using commands like docker push and docker pull makes both publishing and retrieving Docker images easy.
Installing Docker is straightforward. You'll want to follow the official documentation for your OS to get started.
Docker is open-source and free by nature. Docker has a community edition (DCE) and an enterprise edition (DEE)
DCE is free. DEE has costs associated with support which aren't clearly defined anywhere...
Docker containers provide a more efficient use of the host machine than traditional VMs. Most VMs rely on a hypervisor to isolate processing. A hypervisor is a process that separates an OS from it's underlying hardware so that virtual "machines" can run on the same hardware.
While hypervisors effectively create VMs, the processing involved is usually overkill for the underlying need of an application running on that VM.
This is where Docker presents an advantage as it doesn't require a hypervisor but instead leverages the existing host kernal.