00 - Containers - Docker & Docker Compose
Introduction
A Container is the virtualization of an operation system with the purpose of executing one service in an isolated environment. A container is very lightweight compared to a virtual machine as it doesn’t recreate a whole computer, but reuses the host kernel and accesses its resources natively.
Containers are the best way to deploy and test new self-hosted software as they encapsulate the main process into its own eco-system and don’t interfere with the rest of services running in that host.
The following video does an excellent job at trying to explain the differences between bare-metal, virtualization and containerization, give it a watch:
So for the sake of simplicity and fast testing, we’re going to use Docker as the container engine and docker compose for the workload deployment.
Getting started
Go to the official Docker documentation to check how to install Docker and Docker Compose on your operating system:
Follow the excellent instructions of TechnoTim to get an idea of what we need to do:
- Docker and Docker compose installation: Link
Installation steps
Docker and Docker compose
I’m going to follow Technotim’s guide as my server OS is Ubuntu.
There’s really nothing much to say here, just follow the instructions, make sure that you have Internet access to install the packages and check that your user can execute docker
commands, like docker version
, and docker compose
.
Also, remember to add your user to the docker
group so you don’t need privileged permissions to operate with it:
Once done, log out and log in again to your server to apply the changes on the user groups.
Networking in Docker
Overlay network
An overlay
network is a type of virtual network in Docker that allows multiple Docker hosts to communicate between them. This is pretty handy if, for example, you need some services deployed with Docker in a host to access an authentication service that is hosted on a different Docker host.
In order to use this, do we need to install docker swarm
?
You can find the official Docker docs regarding overlay networking here.