Docker — Introduction to technology from entry to practice: install Docker


There are a variety of environments on the official website of the installation guide , here introduces the next Ubuntu, Debian and CentOS series of installation.

Install Docker on Ubuntu, Debian series

System requirements Docker supports the following versions of Ubuntu and Debian operating systems: Ubuntu Xenial 16.04 (LTS)
Ubuntu Trusty 14.04 (LTS)
Ubuntu Precise 12.04 (LTS)
Debian testing stretch (64-bit)
Debian 8 Jessie (64-bit)
Debian 7 Wheezy (64-bit) (backports must be enabled)

In the Ubuntu release, the LTS (Long-Term-Support) long-term support version will receive 5 years of upgrade and maintenance support. This version will be more stable, so the LTS version is recommended in the production environment. The Ubuntu version currently supported by Docker is at least 12.04 LTS, but for stability considerations, 14.04 LTS or higher is recommended. Docker needs to be installed on a 64-bit x86 platform or ARM platform (such as Raspberry Pi), and the kernel version must be at least 3.10. But in fact, the newer the kernel, the better. A kernel version that is too low may cause some functions to be unusable or unstable. Users can check their own kernel version details with the following command:

$ uname -a
Linux device 4.4.0-45-generic #66~14.04.1-Ubuntu SMP Wed Oct 19 15:05:38 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

Upgrade Kernel
If the kernel version is too low, you can use the following command to upgrade the system kernel.

Ubuntu 12.04 LTS

sudo apt-get install -y --install-recommends linux-generic-lts-t rusty

Ubuntu 14.04 LTS

sudo apt-get install -y --install-recommends linux-generic-lts-x enial

Debian 7 Wheezy
The default kernel of Debian 7 is 3.2. To meet the needs of Docker, the backports kernel should be installed.
Execute the following command to add backports source:

$ echo "deb http://http.debian.net/debian wheezy-backports main" 
	| sudo tee /etc/apt/sources.list.d/backports.list

Upgrade to the backports kernel:

$ sudo apt-get update 
$ sudo apt-get -t wheezy-backports install linux-image-amd64

It should be noted that after upgrading to the backports kernel, because the AUFS kernel module is not available, the default devicemapper driver will be used and the loop-lvm configured, which is not recommended. Therefore, don't forget to configure the overlay2 storage layer driver after installing Docker.

Configure GRUB boot parameters
During the use of Docker, or in the docker info message, you may see the following warning message:

WARNING: Your kernel does not support cgroup swap limit. WARNING 
: Your 
kernel does not support swap limit capabilities. Limitation disc arded.

or

WARNING: No memory limit support 
WARNING: No swap limit support 
WARNING: No oom kill disable support

If you need these functions, you need to modify the GRUB configuration file /etc/default/grub and add the kernel boot parameter cgroup_enable=memory swapaccount=1 in GRUB_CMDLINE_LINUX.
Then don't forget to update GRUB:

$ sudo update-grub 
$ sudo reboot

Automated installation using script

In order to simplify the installation process, Docker officially provides a set of installation scripts. Ubuntu and Debian systems can use this script to install:

curl -sSL https://get.docker.com/ | sh

After executing this command, the script will automatically complete all preparations and install Docker in the system.
However, due to the great wall, using this script in China may cause some download errors. Some domestic cloud service providers provide a modified version of this script to use the domestic Docker software source image to install, so as to avoid wall interference

Alibaba Cloud installation script

curl -sSL http://acs-public-mirror.oss-cn-hangzhou.aliyuncs.com/ docker-engine/internet | sh -

DaoCloud installation script

curl -sSL https://get.daocloud.io/docker | sh

Manual installation
Install the required software packages
Optional kernel modules
Starting from Ubuntu 14.04, some kernel modules have been moved to optional kernel module packages (linux-image-extra-*) to reduce the size of the kernel software packages. The normally installed system should contain optional kernel module packages, and some tailored systems may streamline them. The AUFS kernel driver is part of the optional kernel module. As the recommended Docker storage layer driver, it is generally recommended to install the optional kernel module package to use AUFS.
If the optional kernel module is not installed in the system, you can execute the following command to install the optional kernel module package:

$ sudo apt-get install linux-image-extra-$(uname -r) linux-image -extra-virtual

12.04 LTS Graphical Interface
In the Ubuntu 12.04 desktop environment, some additional software packages are required, which can be installed with the following command.

$ sudo apt-get install xserver-xorg-lts-trusty libgl1-mesa-glx-l ts-trusty

Adding APT mirror source
Although there is Docker in the Ubuntu system software source, named docker.io, this version in the system source should not be used because its version is too old. We need to use the official software source provided by Docker, so we need to add the APT software source.
Since the official source uses HTTPS to ensure that the software is not tampered with during the download process. Therefore, we first need to add the package using HTTPS transmission and the CA certificate.
Some domestic software source images (such as Alibaba Cloud) do not care too much about the details of system security, and may still use insecure HTTP. For these sources, this step may not be performed.

$ sudo apt-get update 
$ sudo apt-get install apt-transport-https ca-certificates

In order to confirm the validity of the downloaded package, you need to add the GPG key of the official Docker software source.

$ sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net :80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D

Then, we need to add the Docker software source to source.list. The following table lists the APT sources corresponding to different Ubuntu and Debian versions

Install Docker

After everything is ready, you can install the latest version of Docker, the package name is docker-engine.

$ sudo apt-get install docker-engine

If there is an old version of Docker (lxc-docker, docker.io) in the system, you will be prompted whether to delete it first, just select yes.

Start the Docker engine

Ubuntu 12.04/14.04、Debian 7 Wheezy

$ sudo service docker start

Ubuntu 16.04、Debian 8 Jessie/Stretch

$ sudo systemctl enable docker $ sudo systemctl start docker

Establish docker user group
By default, the docker command will use Unix socket to communicate with the Docker engine. Only the root user and users in the docker group can access the Unix socket of the Docker engine. For security reasons, root users are not directly used on Linux systems. Therefore, it is better to add users who need to use docker to the docker user group.
Create a docker group:

 $ sudo groupadd docker 

Add the current user to the docker group:

 $ sudo usermod -aG docker $USER

补充

Install Docker on CentOS operating system

Guess you like

Origin blog.csdn.net/qq_46914021/article/details/109220285