Introduction
Docker is used for creating, deploying, and managing containers for application development. It uses OS virtualization to isolate containers and allow them to communicate with each other.
In this tutorial, you will learn how to install Docker on Debian 10.
Prerequisites
- Debian 10 installed and configured
- Access to a command line/terminal window
- A user account with sudo privileges
Docker on Debian 10
To set up Docker, you will need to prepare the system for installation. Deleting older versions of Docker packages and downloading the required dependencies speeds up the process.
Step 1: Uninstall Default Docker Packages
The first step is to remove old versions of docker
, docker.io
, and docker-engine
that may already be on the system. These versions are not required for the latest stable release of Docker.
Delete the outdated packages by typing the following command in the terminal:
sudo apt-get purge docker lxc-docker docker-engine docker.io
Step 2: Install Required Packages
Update the default repository with the command:
sudo apt-get update
Download the following dependencies:
sudo apt-get install apt-transport-https ca-certificates curl gnupg2 software-properties-common
By doing so, this allows you to add a new repository over HTTPS.
Step 3: Install Docker
There are several ways to install Docker:
- The standard and most practical approach is to set up Docker repositories and install the software from them.
- Alternatively, download the DEB package and install Docker manually. This method is recommended for users that have air-gapped systems with no access to the internet.
- If you have Raspbian, the only way to set up Docker is by using automated convenience scripts.
Method 1: Install Docker Using the Repository on Debian 10
The best option for most Debian 10 users will be to install Docker from its official repositories. To do so, follow the steps outlined below.
1. Download Docker’s official GPG key to verify the integrity of packages before installing:
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
2. Add the Docker repository to your system repository with the following command:
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian buster stable"
3. Update the apt repository:
sudo apt-get update
4. Install Docker Engine – Community (the latest version of Docker) and containerd
:
sudo apt-get install docker-ce docker-ce-cli containerd.io
5. The service will start automatically after the installation. Check the status by typing:
sudo systemctl status docker
6. You can also verify the installation by asking for the Docker version:
docker -v
Method 2: Install Docker Manually on Debian 10
Users who cannot install Docker from its repositories (or prefer not to) have the option of installing the software manually.
1.Navigate to the following URL:
2. Click the version of Debian you are using. In this case, it is Buster.
3. Click pool > stable, and finally amd64.
4. Next, you will see a list of all the available .deb packages, including the new releases and older versions. The list will consist of multiple versions of three essential Docker packages:
- containerd
- docker-ce-cli (Docker’s command user interface)
- docker-ce
Unless you require a specific version, go for the latest stable release. Click the newest version for each software package to download them.
The system will most often store the .deb files in the Downloads folder.
5. Return to the command line and navigate to the Downloads folder with the following command:
cd Downloads
6. To set up Docker, use the dpkg
command to install each of the three packages. Make sure to do it in the following order:
sudo dpkg -i containerd.io_1.2.6-3_amd64.deb
sudo dpkg -i docker-ce-cli_19.03.3~3-0~debian-buster_amd64.deb
sudo dpkg -i docker-ce_19.03.3~3-0~debian-buster_amd64.deb
Step 4: Verify the Installation With a Hello World Image
The best way to ensure that the container service has been configured correctly is to run a hello-world test image.
docker run hello-world
The command automatically downloads the hello-world image. It also creates a container based on that image.
The following output will appear in the terminal, verifying that you have successfully configured Docker on Debian 10:
Hello from Docker!
This message shows that your installation appears to be working correctly.
Bonus: Uninstall and Remove Docker
If you need to uninstall Docker, run the following command:
sudo apt-get purge docker-ce
The command deletes the docker-ce
package. However, any additional files related to it, such as images, containers, and custom configuration files, remain on the system. Remove everything from the Docker directory with the command:
sudo rm -rf /var/lib/docker
Conclusion
Now that you know how to install Docker on Debian 10, you can also get started with learning the basic commands and functions.
If you have never worked with Docker containers, we highly recommend reading how to list, start, and stop Docker containers next.
原创文章,作者:bd101bd101,如若转载,请注明出处:https://blog.ytso.com/223031.html