How to Install Docker Debian on VPS
Docker is a powerful containerization platform that simplifies application deployment and management. If you're running a Virtual Private Server (VPS) with Debian as your operating system, this guide will walk you through a step-by-step process on how to install Docker debian on your VPS.
Prerequisites to Install Docker on Debian VPS
Before you begin, ensure that you have:
- A VPS running Debian 12.
- A 64-bit System.
- SSH access to your VPS with administrative privileges.
If you don't already have a VPS, sign up on Vultr and get $100 of credit.
Steps to Install Docker Debian Steps
Step 1: Update the System
It's essential to update your system packages.
Login to your VPS from the terminal and run the command below to update your existing list of packages.
sudo apt update
This command is mostly run after a fresh system install or before installing a new software package.
The apt update
command updates the local package index of a Linux system or package list, which is a database of available
packages and their versions. It does not actually install any updates; it only refreshes the information about available packages from the
repositories.
Step 2: Upgrade the System
Need to upgrade your software packages to their latest versions? Then apt upgrade
is the command to execute.
sudo apt upgrade
The apt upgrade
command, without any arguments, upgrades all outdated packages residing on your system to their latest versions.
To list packages that are due for an upgrade, you run the apt list --upgradable
command.
Step 3: Reboot the System
Depending on the packages you have installed. It's advisable to reboot the system.
reboot
After the system reboots, you have to log back into your Debian VPS.
Step 4: Install Required Dependencies
Docker requires some dependencies to be installed. Install them using the following command:
sudo apt -y install apt-transport-https ca-certificates curl gnupg2 software-properties-common
These dependencies let apt use packages over HTTPS.
Step 5: Add Docker Repository
To install Docker, you'll need to add the Docker repository to your system.
Add the GPG key for the official Docker repository to your system:
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
Add the Docker repository to APT sources:
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list
Step 6: Update packages
Update the package index with the Docker packages from the newly added repo:
sudo apt update
After updating the packages list you are now ready to install Docker Debian on your VPS.
Step 7: Install Docker Engine
Now, it's time to install Docker on your VPS:
sudo apt install -y docker-ce docker-ce-cli containerd.io
Docker Engine and CLI are now installed on your VPS running Debian.
Step 8: Start and Enable Docker
To ensure Docker starts automatically after system reboots:
sudo systemctl enable docker
sudo systemctl start docker
Step 9: Verify Docker Installation
Check if Docker is installed correctly by running the following command:
sudo docker --version
You should see the Docker version information displayed, confirming a successful installation.
Step 10: Allow a Local User to Run Docker Command (Optional)
The docker
command by default can only be run by the root
user or by a user in
the docker
group.
To allow a local user to run docker commands without prefixing it with sudo
, add the user to the docker group using the usermod command:
sudo usermod -aG docker ${USER}
Step 11: Run a Test Container
Let's run a simple test container to verify Docker's functionality:
sudo docker run hello-world
This command will pull a small test image and run it. If successful, you'll see a message indicating that your installation appears to be working correctly.
Conclusion
Congratulations! You've successfully installed Docker on your Debian-based VPS. You're now ready to leverage the power of containerization to deploy and manage your applications efficiently.
In this tutorial, we covered how to install Docker on Debian, and you're now equipped with the knowledge to explore and utilize Docker for your development and deployment needs.
Remember to manage your containers, images, and resources efficiently as you build and scale your applications using Docker.
Now you can harness the full potential of Docker for Linux, as you've successfully learned how to install Docker on Debian.