An Introduction to Docker
What is docker?
Docker is an open-source platform that lets you execute complete applications and their surroundings in logical containers. On a single server, we can execute several Docker containers. Applications are segregated from one another. Docker makes use of OS-level virtualisation to run several Docker containers on a single piece of hardware.
What is Container?
A container is nothing more than a running container image. The containers are separated from both the host and one another.
Architecture of Docker
As the above diagram shows, containers share their Linux kernel with the host. Unlike virtual machines, we don't require to install entire operating systems in docker containers. The Docker daemon is in charge of managing the containers and resources they utilize. While deploying the applications on containersI, we don't need to install entire application on one container. We can install Apache/Nginx, MySQL, and PHP on separate containers.
Installation
Installation on Ubuntu
As per the docker documentation, at present following are the 64-bit OS supported:
- Ubuntu Impish 21.10
- Ubuntu Hirsute 21.04
- Ubuntu Focal 20.04 (LTS)
- Ubuntu Bionic 18.04 (LTS)
sudo apt-get update
sudo apt-get install ca-certificates curl gnupg lsb-release
# Add gpg
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
# Add to resource list
echo "deb [arch=$(dpkg --print-architecture) signedby=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
Now, we can install the docker using apt
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin
# If docker-compose isn't installed
sudo curl -L "https://github.com/docker/compose/releases/download/2.5.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
Check the docker-compose
version.
docker-compose --version
Installation on MacOs
Visit the website https://docs.docker.com/desktop/mac/install/
and download the version required for your Mac. Double click the dmg file and follow the instructions.
Installation on Windows
On windows, download the executable from here.
Double-click Docker Desktop Installer.exe to run the installer. These instructions are directly take from docker installation page.
When prompted, ensure the Use WSL 2 instead of Hyper-V option on the Configuration page is selected or not depending on your choice of backend.
If your system only supports one of the two options, you will not be able to select which backend to use.
- Follow the instructions on the installation wizard to authorise the installer and proceed with the install.
- When the installation is successful, click Close to complete the installation process.
- If your admin account is different to your user account, you must add the user to the docker-users group. Run Computer Management as an administrator and navigate to Local Users and Groups > Groups > docker-users. Right-click to add the user to the group. Log out and log back in for the changes to take effect.
That's all. Docker is installed on your machine. See you in the next article.