Docker is a platform that allows you to develop, deploy, and run applications in containers. Containers are lightweight, portable, and self-sufficient units that encapsulate everything needed to run a piece of software, including code, runtime, system tools, libraries, and settings. Docker enables you to package an application and its dependencies into a single container, ensuring consistent and reproducible deployment across different environments.
To install Docker on Ubuntu 22.04, follow these steps:
Step 1: Update Package Repositories:
Open a terminal and run the following commands to update the package repositories and ensure you have the latest information about available packages.
sudo apt update sudo apt upgrade
Step 2: Install Docker Dependencies:
Install the required packages to allow apt to use repositories over HTTPS and install software over HTTPS.
sudo apt install apt-transport-https ca-certificates curl software-properties-common
Step 3: Add Docker Repository:
Add Docker’s official GPG key and repository to your system.
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg echo "deb [signed-by=/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
Step 4: Install Docker Engine:
Update your package repositories again and then install Docker.
sudo apt update sudo apt install docker-ce
Step 5: Start and Enable Docker:
After installation, start the Docker service and enable it to start on system boot.
sudo systemctl start docker sudo systemctl enable docker
Step 6: Verify Docker Installation:
Check if Docker is installed and running by running the following command.
sudo docker --version
Step 7: Manage Docker as a Non-Root User (Optional):
By default, Docker requires root privileges. You can add your user to the “docker” group to run Docker commands without using “sudo.”
sudo usermod -aG docker $USER newgrp docker # Activate the group changes
You have now successfully installed Docker on Ubuntu 22.04. Remember that this guide assumes you’re using a system with a clean Ubuntu 22.04 installation. If you encounter any issues during installation, make sure to consult the official Docker documentation for troubleshooting and additional information.