How to Install Docker on Ubuntu/Debian
Docker is a container platform that allows you to develop, ship, and run applications in isolation. This tutorial will guide you through the process of installing Docker on Ubuntu/Debian-based distributions.
Prerequisites
- A system running Ubuntu 18.04 or higher, or Debian 10 or higher.
- Access to the terminal with superuser privileges (sudo).
Step-by-Step Guide
-
Update the System Package Index
First, update the system package index to ensure you are installing the latest available packages:
1
sudo apt-get update
-
Install Required Packages
To allow Docker to use HTTPS, you need to install some prerequisite packages:
1
sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
-
Add Docker’s Official GPG Key
Add Docker’s official GPG key to your system:
1
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
-
Add Docker Repository
Add Docker repository to APT sources:
1
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
-
Update the Package Index Again
After adding Docker repository, update the package index again:
1
sudo apt-get update
-
Install Docker
Now you can install Docker:
1
sudo apt-get install docker-ce
-
Verify Docker Installation
After installation, verify that Docker is installed and running correctly:
1
sudo systemctl status docker
You should see a message indicating that Docker service is active and running.
Optional Steps
-
Add Your User to the Docker Group
To avoid the need to use
sudo
for every Docker command, add your user to the Docker group:1
sudo usermod -aG docker ${USER}
To apply the new group membership, log out and log back in to your system, or use the command:
1
su - ${USER}
-
Test Docker Installation
Test the Docker installation by running the
hello-world
container:1
docker run hello-world
If the installation is correct, you will see a message indicating that Docker is installed successfully and running.
Conclusion
You have successfully installed Docker on your Ubuntu/Debian-based system. Now you can start using Docker containers to develop and deploy your applications efficiently and in isolation.
If you encounter any issues during the installation, refer to the official Docker documentation or seek help from communities like Stack Overflow.
I hope this tutorial has been helpful! If you have any questions or suggestions, please leave a comment below!