A Comprehensive Guide to Installing and Configuring Docker on Ubuntu 22.04
Introduction
Docker, a leading containerization platform, allows developers to build, ship, and run applications consistently across multiple environments. This guide will walk you through the installation and configuration of Docker on the Ubuntu 22.04 LTS release. Know more about Docker Commands : Essential Docker Commands Every Developer Should Know
Prerequisites
Before we begin, make sure you have access to a Ubuntu Linux terminal with administrative privileges on your Ubuntu 22.04 system.
Step 1: Update Package Database
To start, update the package database to ensure you have the latest information about available packages.Â
sudo apt update
Step 2: Install DependenciesÂ
Install necessary dependencies to allow Docker to use repositories over HTTPS.Â
sudo apt install apt-transport-https ca-certificates curl software-properties-common
Step 3: Add Docker’s GPG KeyÂ
Add Docker’s GPG key to ensure the integrity of the downloaded packages.Â
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
Step 4: Set Up Stable Docker Repository
Configure the stable Docker repository for Ubuntu 22.04.Â
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 5: Install Docker EngineÂ
Update the package database and install the Docker Engine.
sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io
Step 6: Manage Docker as a Non-Root User (Optional)Â
sudo usermod -aG docker $USER
Remember to log out and log back in or restart your system for the changes to take effect.Â
Step 7: Verify Docker Installation
Ensure Docker is installed correctly by checking the version.Â
docker --version
Step 8: Run a Docker Container (Optional)Â
Test your Docker installation by running a simple container.Â
docker run hello-world
This should output a message confirming that your Docker installation is operational.Â
Additional Configuration (Optional)
Configure Docker to Start on Boot:
sudo systemctl enable docker
Configure Docker to Use a Proxy (if applicable):
 Create or edit the Docker service configuration file.Â
sudo nano /etc/systemd/system/docker.service.d/http-proxy.conf
Add proxy information.Â
[Service]
Environment="HTTP_PROXY=http://proxy.example.com:80/"
Environment="HTTPS_PROXY=https://proxy.example.com:443/"
Save the file and restart the Docker service.Â
sudo systemctl daemon-reload
sudo systemctl restart docker
Conclusion
Congratulations! Docker has been installed and configured successfully on Ubuntu 22.04. Docker is a powerful containerization platform that allows you to streamline your development and deployment processes. Stay tuned for more tech tutorials and guides on our blog Linux Guru to help you improve your skills and stay current with the latest technologies.Â
You may like this post : Essential Docker Commands Every Developer Should Know