How to setup Docker on Linux

Setting up Docker on a linux machine is pretty easy and can be done in less than 10 minutes. Read on to find out how.

How to setup Docker on Linux

What is Docker?

Docker is an open-source platform that enables developers to automate the deployment, scaling, and management of applications using containerization. Introduced by Solomon Hykes in 2013 under the company DotCloud (later renamed Docker, Inc.), Docker revolutionized software development by providing a standardized unit of software called a container. Containers encapsulate an application and its dependencies, ensuring consistent operation across different environments. In this Blog post, we will take a look at how we can setup Docker ourselves on a linux machine.

Motivation behind Docker

The motivation behind Docker's creation stemmed from the need to address the challenges associated with traditional virtual machines (VMs) and application deployment. Traditional VMs, while providing isolation and resource management, were often resource-intensive and slow to start. Docker containers, on the other hand, are lightweight, start almost instantly, and share the host system's kernel, making them more efficient in terms of both resource utilization and performance.

Docker's introduction has significantly streamlined the development workflow, enabling developers to build, ship, and run applications with unprecedented ease and reliability. By decoupling applications from the underlying infrastructure, Docker facilitates seamless collaboration among development teams, enhances scalability, and supports a microservices architecture, fostering more agile and resilient software development practices.

While containerization was nothing new, but Docker introduced the standardization in container technology. Before that, many other different tools existed which all had their own pros and cons.

Install using the apt repository

  1. To setup Docker on linux machine, we need to set up the Docker repository.
# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

# Add the repository to Apt sources:
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
  $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update

Add Docker's GPG key to Linux keyring

  1. Install the Docker engine and docker-compose packages.
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

Install Docker and all the required dependencies

That is it. We can check whether docker is running or not, by using

sudo systemctl status docker

If you like this blog post, you can subscribe for Free also, to stay up to date and receive emails when new content is published!

As next, you can learn how to self-host Portainer instance yourself.

How to setup Portainer on Linux
If you are thinking of using a linux machine to setup services, best way forward is to use docker-compose and portainer is a free and open-source tool to manage docker-compose with ease. Read on to find how to set up Portainer.

How to setup portainer on Linux