In the world of software development, Docker has become an indispensable tool for creating, deploying, and running applications by using containers. Containers allow developers to package up an application with all of the parts it needs, such as libraries and other dependencies, and ship it all out as one package. This ensures that the application will run on any other Linux machine regardless of any customized settings that machine might have that could differ from the machine used for writing and testing the code. If you’re using Ubuntu 22.04, one of the most popular Linux distributions for both desktop and server environments, installing Docker Engine can streamline your development process significantly.
This guide will take you through the steps to install Docker Engine on Ubuntu 22.04, ensuring you can take advantage of this powerful tool in your development projects.
Prerequisites
Before we begin, ensure that you have:
- A system running Ubuntu 22.04.
- A user account with sudo privileges.
Step by Step Guide
Step 1: Update Software Repositories
Open a terminal and update your package index using the command:
sudo apt update
Step 2: Install Required Packages
To install Docker on Ubuntu, we need to install some necessary dependencies first. Run the following command to install them:
sudo apt install apt-transport-https ca-certificates curl software-properties-common
Step 3: Set Up the Stable Docker Repository
Next, we will add the official Docker repository to our system. First, add the GPG key for the Docker repository:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
Then, add the Docker repository to your system with the following command:
echo "deb [arch=$(dpkg --print-architecture) 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
Now that we have added the Docker repository, update your package index:
sudo apt update
Then, install Docker with the following command:
sudo apt install docker-ce docker-ce-cli containerd.io
Step 5: Verify Docker installation
To verify that Docker has been installed successfully, run the following command:
sudo docker --version
You should see output similar to this, indicating the installed Docker version:
Docker version 25.0.3, build 4debf41
Step 6: Manage Docker service
Docker should now be installed and running as a background service. To check the status of the Docker service, run:
sudo systemctl status docker
If the Docker service is not running, you can start it with:
sudo systemctl start docker
To enable the Docker service to start automatically at boot, run:
sudo systemctl enable docker
Step 7: Running Docker without sudo (optional)
By default, Docker requires sudo privileges to run. If you want to use Docker without typing ‘sudo’ every time, add your user to the ‘docker’ group with the following command:
sudo usermod -aG docker $USER
After running this command, log out and log back in for the changes to take effect.
Conclusion
Following the steps outlined in this guide, you should now have Docker Engine successfully installed on your Ubuntu 22.04 system. With Docker installed, you’re well-equipped to embark on a journey of more efficient, consistent, and scalable application development and deployment. Docker’s ability to package and run applications in containers offers a level of flexibility and portability that traditional deployment methods can’t match. Whether you’re developing complex applications, microservices, or just experimenting with new technologies, Docker provides a robust platform to build, share, and run your applications anywhere. Remember, the Docker ecosystem is vast and full of resources, so don’t hesitate to explore further documentation, tutorials, and community forums to enhance your Docker skills and knowledge.