Docker is a platform for developing, shipping and running containerised applications.
Docker enables you to decouple applications from infrastructure allowing you to deliver software quickly and at scale.
Disadvantages of Virtual Machines
Virtual Machines (VM) are abstraction of physical hardware.
They allow you to turn one server into many servers. A hypervisor allows multiple VMs to run on a single machine.
However the downside to this is that each VM contains a full copy of the operating system and other necessary binaries and dependencies. This equates to gigabytes worth of space that is use.
In addition VMs can be slow to boot.
Benefits of Docker Containers
Docker containers run on the Docker Engine.
Standardised – Containers are portable and deployable anywhere
Lightweight – Containers share machine resources such as the OS kernel and therefore do not require and OS per application. Therefore servers can run more efficiently.
Secure – Applications are safer in containers since they are isolated external actors.
Microservices – Docker lends itself very well to the microservice architecture and containerising different components of the application into individual containers.
In addition, since all dependencies, code, runtimes and binaries are all packaged into a single container, we can guarantee that the container will run correctly regardless of where it is deployed and no matter the environment. Containers run the same anywhere.
The Docker Engine is a client server application comprised of three main components:
- A server, also known as the Docker Daemon which is a long running application.
- A REST API which specifies interfaces that programs can use to talk to the daemon and instruct it what to do.
- A CLI (command line interface) client.
The Docker architecture is client-server.
The Docker client communicates with the Docker daemon, the daemon does the heavy lifting of building, running and distributing the Docker images.
The Docker client and daemon can run on the same system, or the daemon can be remote.
Docker Images are templates with instructions on how to create Docker Containers.
An executable package that includes everything needed to run an application.
The code, runtime, libraries, environment variables and configuration files.
A runtime instance of an image.
It is what the image becomes in memory when executed.
Services are containers in production and allow you to scale containers across multiple Docker daemons. They work together as a swarm with multiple managers and workers.
A Service only runs one image and it codifies the way the image is run i.e. ports, replicas etc. so that it has the resources it needs.
In a distributed application, Services represent different pieces of the application.
Scaling a service changes the number of container instances running that piece of software.
A group/cluster of machines running Docker.
You use the same Docker commands, but they are now executed on a cluster by a swarm manager.
The machines in a swarm can be physical or virtual.
After joining a swarm, they are referred to as nodes.
Docker Stack is used in Docker Swarm.
A single stack is capable of defining and coordinating the functionality of an entire application.
A stack is a group of interrelated services that share dependencies.
They can be orchestrated and scaled together.
A dockerfile is a file used to create a docker image. It uses a simple syntax to define the steps needed to create and run an image.
Each instruction in the dockerfile creates a layer in the image. When the dockerfile is changed and the image is rebuilt, only the layers that have changed are rebuilt.
This another benefit of Docker images lightweights, small and fast compared to other virtualization technologies.
Docker Compose is a tool for defining and running multi-container Docker applications.
docker-compose.yml file configures the applications services, then with a single command
docker-compose up Docker will run your entire application.
Tools that manage, scale and maintain containerised applications are called orchestrators.
The two most common are Docker Swarm and Kubernetes.
How To Run Containerised Docker Applications in AWS
There are several methods of deploying containerised applications on AWS.
Fargate is a fully managed serverless compute service for containers.
Fargate removes the need to provision and manage servers
EC2 is another option for deploying containers.