12/27/2021

Install Docker Engine Debian

72

Docker is a container-based application framework, which wraps a specific application with all its dependencies in a container. Docker containers can easily to ship to the remote location on start there without making entire application setup. This tutorial will help you to install Docker on Debian 10 Buster Linux distribution.

Debian Docker 安装 Docker 支持以下的 Debian 版本: Buster 10 Stretch 9 (stable) / Raspbian Stretch Docker Engine-Community 在 x8664(或 amd64 )armhf,和 arm64 体系结构上受支持。. Now you're ready to install Docker to Debian 11 Bullseye. Installing Docker on Debian 11. If your system has Docker installed from the Debian repository before, you must remove it using the command below. Sudo apt remove docker docker-engine docker.io containerd runc. After that, you can install Docker again using the apt command below.

Step 1 – Prerequisites

First of all, remove any default Docker packages from the system before installation Docker on a Linux VPS. Execute commands to remove unnecessary Docker versions.

Now, install some required packages on your system for installing Docker on Debian system. Run the below commands to do this:

Engine

Step 2 – Setup Docker PPA

After that, you need to import dockers official GPG key to verify packages signature before installing them with apt-get. Run the below command on terminal.

After that add the Docker repository on your Debian system which contains Docker packages including its dependencies. You must have to enable this repository to install Docker on Debian.

Step 3 – Install Docker on Debian 10

Your system is now ready for Docker installation. Run the following commands to upgrade apt index and then install Docker community edition on Debian.

After successful installation of Docker community edition, the service will start automatically, Use below command to verify service status.

Your system is now ready for running Docker containers. Use our Docker Tutorial for Beginners to working with Docker.

Step 4 – How to Use Docker

Install Docker Engine Debian

After installation of Docker on a Linux. Here are some basic details for search and download Docker images, launch containers and manage them.

Search Docker Images

Download Docker Images

Now make sure that the above images have been downloaded successfully on your system. Below command list all images.

Launch New Container with Image

To exit from docker container type CTRL + P + Q. This will leave container running in the background an provide you host system console. If you used the exit command, it will stop the current container.

After exiting from Docker container, execute below command to list all running containers.

By default Above command will list only running containers. To list all containers (including stopped container) use the following command.

Start/Stop/Attach Container

Engine

You can start, stop or attach to any containers with following commands. To start container use following command.

To stop container use following command.

To attach to currently running container use following command.

Step 5 – Remove Docker

To remove docker from your Debian system run following command.

As our colleague Joaquín García explained in an extensive article in No Country for Geeks, Docker is a platform for running applications in containers. These containers are a virtualization method that includes everything imaginable to easily package an entire environment.

Given the flexibility with which different applications can be deployed on the same server and their independence from resources, and yet being able to communicate with each other, it becomes my preferred option to build piece by piece the whole ecosystem of my home server.

On the other hand Portainer “installed” as a container, gives us the power to mount containers on Docker and configure everything in a visual way. It even comes with templates with applications already prepared in containers to make its configuration even easier.

Prerequisites

Although in theory the following installation of Docker and Portainer can be done on any operating system based on Linux, we all know that depending on the distribution and version there are small differences. So, for the following steps in my case these prerequisites are fulfilled:

  • Debian 10 64 Bit on a Mini-PC. Any other distribution based on Debian like Raspbian should also work.
  • Repositories updated with the commands sudo apt-get update, sudo apt-get upgrade and sudo apt-get dist-upgrade.

Installing packages and configuring the repository

We are missing a requirement, to add the repository in order to install Docker package.

  1. Install the following packages to allow apt to use secure repositories over HTTPS. Execute the following commands in the console, one by one:

  2. Add the official GPG keys for Docker.

    You can check that you have the key with his fingerprint with the command:

  3. Add the repository to the list of repositories to get Docker.

    The command lsb_release -cs returns the name of the installed Debian distribution (e.g. buster for Debian 10).

    The arch parameter it is necessary to indicate the architecture of your device, you must choose between amd64, armhf or arm64 options.

  4. Finally, update the package collection.

Install Docker Engine

To install the latest stable version of Docker Engine just run:

After a few seconds you can check that Docker has been installed correctly by asking for the installed version and running the test hello-world image.

To finish with the installation of Docker, it is recommended to add the regular user as Docker administrator by adding him to the docker group.

Portainer

Now that Docker Engine is installed on the server, you can run images through containers. One of the easiest ways to manage these containers, their volumes, the images… is with Portainer.

Creating a volume

First, you are going to create a volume for the Portainer data. A volume is nothing more than a data persistence mechanism to store data used and generated by a Docker container. This way, even if you delete, update, or break the container, the application’s configuration data will still be safe so that you can redeploy a new container from the same image without further concern.

Install Docker Engine Debian 10

There is some discussion about whether it is better to use volumes or mount a host folder for data persistence. In most cases that you will handle, it is a matter of taste - try both!

Installation Docker-engine Debian

Although they can be viewed later from Portainer, you can look at the volume listing and inspect one to see among other things the directory where the files are located on the server using the commands:

Install Portainer

Leaving aside the ‘hello_world’ container, let’s mount your first container, this time based on the image of Portainer. Execute the command:

As it is a quite long command, it is recommended to know the docker commands although it can be done visually from Portainer, I will explain each part:

  • docker run -d: Create a container with the following configuration if it does not exist and start it.
  • --name=Portainer: The name of the container. This is important because you can have several containers based on the same image.
  • --hostname=Portainer: The name of the container machine. Optional, but it is very useful to configure this parameter to see at a glance this name when we access by console and associate that this terminal is from this container. (Thanks to @Rapejim for the tip).
  • --network=host: The host networking uses the IP address of the host running docker such that a container’s networking appears to be the server rather than separate.
  • --restart=always: Restart the container if it stops. If it stops manually, it is only restarted when the container is manually restarted, or the Docker service is restarted.
  • -v /var/run/docker.sock:/var/run/docker.sock: Links a server folder (left), with a container folder (right). In this case as Portainer will have access to the server containers, it links its information with the docker.sock file.
  • -v portainer_data:/data: Links the volume, with the Portainer configuration folder inside the container.
  • -e TZ='Europe/Madrid': Although it is not necessary, I usually like to manually set the time zone for the container.
  • portainer/portainer: Indicates the image used to mount the container. If no version is specified, it will take the latest stable version.

Using Portainer

Then, open a Web browser on any device that is connected to the same network as the server and access the address: http://SERVERIP:9000/.

When accessing for the first time, the registration screen will open to enter the data of the Portainer administrator user.

Then he will ask for the type of installation. Select Local.

The next screen will be the Dashboard from which you can see the mounted containers, downloaded images, configured volumes… The next steps are to learn a little more about Docker, and start configuring containers and then see their status from Portainer.

Bonus: Portainer App Templates

One of the most powerful sections of Portainer is App Templates. From this tab you can easily create containers and stacks ready to deploy with a couple of options.

Simply select the application to be deployed, fill in the fields shown and click on Deploy. He will do the rest.

If you still can’t find templates for the applications, you can create your own from the Add template button. Or search the internet for a more complete list of templates and add them from Settings -> App Templates -> Use external templates.

I recommend the list SelfHosted templates by ShelfHostedPro.

Bonus 2: Keep your containers up to date

With the container system, application files are usually static, that is, the folders and files saved inside the volume are usually the files that change, settings, data… but the rest of the container has files that do not change with use. That is why, although in some cases, if you update an application with the typical dialog, the application may be updated. The appropriate thing to do is to update the container with the new image that will contain the new version and save only the persistent data saved in the volume.

To do this, just enter the container from Portainer and click on Recreate. If the container is configured with a branch it will download the last image of that branch and reload the container from scratch, respecting the volume contents.

But how do you know if there are images with pending updates? Many times, you will not be interested in updating, but @SolarNeron shares with us a very good option to be notified of new versions. Most images are hosted and create images with new versions in GitHub repositories. You can use this feature to your advantage.

For example, this is the repository of the Portainer image.

From GitHub, you will only need to click on Watch -> Releases only and you will receive a notification in GitHub and in your mail every time a new version is deployed. Again, you’ll just have to recreate the container to update the image and the application.

Conclusion

Install Docker Engine On Debian

Using Docker you will be able to deploy and manage applications in your server in a simple but very powerful way, being able to control the persistent data and being able with Portainer to carry all this management in a visual way. Try to try some applications that you see interesting to learn how the container virtualization system can be one of the best alternatives for your server.

  • Most Viewed News

    • Mojave Download Macos
    • Utorrent Not Downloading Mac 2019
    • Install Python Mac
    • Google Classroom Apk For Mac
    • Google Meet Download On Macbook