How to deploy Docker Community Edition in Ubuntu/Linux
Docker CE is the open-source version of Docker, which is the core component that allows you to run and manage containers on your system. The Docker CLI package provides the command line tools to interact with the Docker daemon and manage containers. containerd.io package is a container runtime that provides an API for interacting with the Linux kernel’s container features.
Installing Docker in Ubuntu
By installing these packages, you will have the Docker service running on your Ubuntu 22.04 LTS and be able to start, stop, and manage containers.
The below blog will help you to understand the commands which are useful to install the Docker Community Edition package, the Docker command line interface package, and containerd.io package, which allows you to run and manage containers on your Ubuntu 22.04 LTS.
- Launch a VM on AWS/Azure or on-prem vmware with OS Ubuntu 22.04 LTS
- A user account with sudo privileges
- VM should have access to internet connectivity to download docker packages.
- Step 1: Update your Ubuntu packages by running the below command:
sudo apt-get update
- Step 2: Install the required packages by running the below command:
sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
Essentially these packages are required for their specific use such as apt-transport-https is required for connecting to the Docker repository over HTTPS, which is a more secure way of connecting to a repository than HTTP.
ca-certificates package is required for validating the repository’s SSL certificate, which is necessary for secure communication over HTTPS.
curl package is required for downloading files from the internet, which is needed for adding the Docker GPG key.
gnupg-agent package is required for managing GPG keys, which is needed for adding the Docker GPG key.
software-properties-common package is required for managing software properties, which is needed for adding the Docker repository.
- Step 3: Add the Docker official GPG key by running the below command:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg|sudo apt-key add -
The command “curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -” adds the Docker official GPG key to the system, which is used to sign the Docker package and ensure its authenticity.
A GPG key is a public key used for encrypting and signing data. In this case, the Docker official GPG key is used to sign the Docker package, and adding the key to the system allows apt-get to verify the authenticity of the package before installing it. This is an important security measure that ensures that the package you are installing is the official version provided by Docker, and not a malicious version provided by an attacker.
- Step 4: Add the Docker repository to your sources list by running the below command:
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
The command “sudo add-apt-repository “deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable”” adds the Docker repository to your system’s sources list.
A sources list is a list of repositories that apt-get uses to search for and install packages. By adding the Docker repository to the sources list, apt-get will be able to find and install the Docker package from that repository.
The command also specifies the architecture (arch=amd64) and the version of Ubuntu you are using (lsb_release -cs) for the Docker package, so that the appropriate package for your system will be installed. The stable version of Docker package is specified at the end.
In summary, adding the Docker repository to your sources list allows apt-get to find and install the Docker package, and specifying the architecture and version of Ubuntu ensures that the appropriate package for your system is installed.
- Step 5: Install Docker by running the below command:
sudo apt-get install docker-ce docker-ce-cli containerd.io
The command “sudo apt-get install docker-ce docker-ce-cli containerd.io” installs the Docker Community Edition (CE) package, the Docker command line interface (CLI) package, and containerd.io package on your Ubuntu 22.04 LTS.
- Step 6: Check Status of Docker
systemctl status docker
Wow! Docker successfully installed and active!