Installation environment: Ubuntu 18.04
The Ubuntu system's support for Docker is very mature, as long as it is 64-bit.
The minimum Ubuntu version currently supported by Docker is 14.04 LTS, but in terms of stability, it is recommended to use 16.04 LTS or 18.04 LTS version, and the newer the system kernel is, the better to support the latest features of Docker.
View detailed kernel version information: (choose one of the two) uname−a cat /proc/version
First, you need to install apt-transport-https and other software packages that support https protocol sources:
sudoapt−getupdate sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
Add the gpg key of the source:
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-get add -
OK
Confirm the public key:
$ sudo apt-key fingerprint 0EBFCD88
Get the code name of the current operating system:
$ lsb_release -cs
bionic
Add the official software source of the Docker stable version: (note that the "bionic" section is consistent with the code name viewed)
$ sudo add-apt-erpository
“deb [arch=amd64] https://download.docker.com/linux/ubuntu
bionic stable”
After the addition is successful, update the apt package cache again:
$ sudo apt-get update
After adding the source, you can install the latest version of Docker. The package name is docker-ce, which represents the community version:
$ sudo apt-get install -y docker-ce
If there is an older version of Docker in the system, you will be prompted whether to delete it first, just select Yes.
After the installation is successful, the Docker service will be started automatically.
View docker information:
sudo docker version
In order to avoid the need to switch to a privileged identity every time you use the Docker command, you can add the current user to the docker user group automatically created during the installation: (the USER_NAME part is the current user name)
sudo username -aG docker USER_NAME
The user updates the group information, it will take effect after logging out and logging in again.
The Docker service startup actually calls the dockerd command, which supports a variety of startup parameters. Therefore, the user can directly start the Docker service by executing the dockerd command, such as the following command to start the Docker service, enable the debug mode, and monitor the local port 2376:
$ dockerd -D -H tcp://127.0.0.1:2376
These options can be written into the daemon.json file under the /etc/docker/ path and read when the dockerd service starts:
{
”debug”: true,
”hosts”: [“tcp://127.0.0.1:2376”]
}
Of course, the operating system also encapsulates the Docker service. Taking Ubuntu as an example, the default configuration file of the Docker service is /etc/default/docker. You can modify the service startup parameters by modifying the DOCKER_OPTS, for example, let the Docker service open the network Monitoring on port 2375:
DOCKER_OPTS=”$DOCKER_OPTS -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock”
After modification, restart the Docker service through the service command:
sudo service docker restart
In addition, the download speed is slow when using a foreign mirror source. Modifying the mirror source can speed up the download speed. Switch to root privileges, open the /etc/docker/daemon.json file, and add the following content:
{
“registry-mirrors”: [
“https://kfwkfulq.mirror.aliyuncs.com",
“https://2lqq34jg.mirror.aliyuncs.com",
“https://pee6w651.mirror.aliyuncs.com",
“https://registry.docker-cn.com",
“http://hub-mirror.c.163.com"
],
“dns”: [“8.8.8.8”,”8.8.4.4”]
}
In addition, if the service is abnormal, you can solve the problem by viewing the log information of the Docker service. On the Ubuntu system, you can execute journalctl -u docker.service
After restarting the Docker service each time, you can check the docker information (docker info
command) to ensure that the service is running normally.
Recommended Posts