Free Online Toolbox for developers

Installing Docker on Linux

Welcome to the first article in a series about Docker. I recently discovered Docker, and I’m already impressed. I was fortunate enough to attend a Docker training as part of my job.

To start, let’s learn how to install Docker on different GNU/Linux distributions:

Ubuntu Debian CentOS

Preamble

Docker revolutionizes the way we build, ship, and run applications by providing a lightweight and efficient containerization platform. With Docker, you can package your application and its dependencies into a self-contained unit called a container, ensuring consistency across different environments. This eliminates the “it works on my machine” problem and simplifies application deployment and management.

Installing Docker on Ubuntu

// Start by updating the package list
sudo apt-get update

// Install Docker
sudo apt install docker.io

// Start the Docker service
sudo systemctl start docker

// Finally, enable the Docker service on startup
sudo systemctl enable docker

Installing Docker on Debian

// Start by updating the package list
sudo apt update

// Install necessary packages for APT to retrieve Docker
docker
sudo apt install apt-transport-https ca-certificates curl gnupg2-agent software-properties-common

// Add the GPG key for the official Docker repository
curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add -

// Add the Docker repository to APT sources
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable"

// Update the package list again
sudo apt update

// Install Docker (and optionally containerd)
sudo apt install docker-ce docker-ce-cli containerd.io

// Start Docker service
sudo service docker start

Installing Docker on CentOs

// Install yum-utils and add the Docker repository
sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

// Install Docker (and optionally containerd)
sudo yum install docker-ce docker-ce-cli containerd.io

// Start Docker
sudo systemctl start docker

// Finally, enable the Docker service on startup
sudo systemctl enable docker

If you encounter any issues, the official documentation is available: Docker Installation Docs.

If you want to test Docker without installing anything, it’s possible! Visit https://labs.play-with-docker.com/. It’s a playground that provides a Linux environment with Docker already installed and pre-configured.

And there you have it, you have successfully installed Docker!




Leave a Reply