Getting Started with Docker on Ubuntu: A Quick Installation Guide
Docker has become an essential tool for developers and system administrators to deploy applications in lightweight, portable containers. These containers encapsulate applications and their dependencies, providing a consistent environment across different systems. In this article, we’ll walk through the straightforward process of installing Docker on Ubuntu using command.
Prerequisites
To install Docker Engine, you need the 64-bit version of one of these Ubuntu versions:
Ubuntu Mantic 23.10
Ubuntu Lunar 23.04
Ubuntu Jammy 22.04 (LTS)
Ubuntu Focal 20.04 (LTS)
Docker Engine for Ubuntu is compatible with x86_64 (or amd64), armhf, arm64, s390x, and ppc64le (ppc64el) architectures.
Uninstall old versions
Run the following command to uninstall all conflicting packages:
for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do sudo apt-get remove $pkg; done
Install using the apt repository
Before you install Docker Engine for the first time on a new host machine, you need to set up the Docker repository. Afterward, you can install and update Docker from the repository.
Add Docker’s official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl gnupg
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
Add the repository to Apt sources:
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
Install the Docker depended packages.
To install the latest version packages, just run this command on your terminal:
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
- Verify that the Docker Engine installation is successful by running the
hello-world
image.
sudo docker run hello-world
This command downloads a test image and runs it in a container. When the container runs, it prints a confirmation message and exits.
Using Docker without sudo
(Optional)
By default, the docker
command requires root privileges. If you'd like to use Docker without sudo
, add your user to the docker
group:
sudo usermod -aG docker $USER
Remember to log out and log back in or restart your system for the changes to take effect.
Must be reboot your machine to get updated features:
reboot
Conclusion
Congratulations! You’ve successfully installed Docker on your Ubuntu machine. This powerful tool opens the door to containerized application development and deployment. As you explore Docker further, you’ll discover its vast ecosystem and features for managing, orchestrating, and scaling containerized applications.
For more detailed information and advanced usage, please comment down bellow. Happy containerizing!