The detailed installation process of Docker under Linux (recommended by the official website, it is feasible to test it yourself)

Preface
I am learning docker recently, and I have found a lot of installation tutorials, which are quite messy, and some tutorials may even have problems. After groping, I have sorted out a docker installation process and made a record.

Note: The installation of docker has requirements for the system, CentOS 7 is required, and the kernel must be 3.10 or above, so it is recommended to use CentOS 7.x version or above (my version is 7.6)

1. If your virtual machine version is still 6.x, it is recommended to change to version 7.x, because I used version 6.8 before, and the installation will fail. 2. Do
not execute yum update before installation. Use this command with caution. It will change the operating system and kernel version, and update a lot of things. The production environment may cause a lot of service dependencies to be updated, causing problems directly, so there is no need to execute this command

The installation process is as follows:

1. Uninstall the old version

If your virtual machine has installed docker before, you need to uninstall the old version first. The command is as follows (you can also execute it if you haven’t installed it):

yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine

2. Install dependent packages

yum install -y yum-utils

3. Set up the mirror warehouse (it is recommended to use the first Alibaba Cloud address, and the second is the official website address, which may be slow or delayed)

yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo(不推荐)

insert image description here

4. Update the yum package index

yum makecache fast

5. Install docker (ce is the community edition, free of charge)

(1) To install the latest version directly, the command is as follows (recommended) (you need to enter y twice during the installation process):

yum install docker-ce docker-ce-cli containerd.io

(2) Choose a version to install by yourself (not recommended)

View the docker version information in the aliyun warehouse: yum list docker-ce --showduplicates | sort -r
select a version to install, such as: yum install docker-ce-17.12.1.ce
insert image description here
6. Start docker

(1) Start and set the boot to start automatically

systemctl start docker
systemctl enable docker

insert image description here
(2) Verify and view version information

docker version

insert image description here
(3) Enable to allow remote access to Docker

Modify a configuration, add after ExecStart: -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock

vi /usr/lib/systemd/system/docker.service

insert image description here
After the modification, wq save and exit, then restart Docker

systemctl daemon-reload
service docker restart

After restarting, in idea, you can connect.
insert image description here
At this point, the docker under Linux has been installed. Although the installation process is not complicated, it took a lot of time before. Alas, some basic information about docker is attached below:

(1) Introduction (from Baidu)

1. Docker is an open source application container engine that allows developers to package their applications and dependencies into a portable image, and then publish it to any popular Linux or Windows machine, and can also implement virtualization. The container is completely using the sandbox mechanism, and there will be no interface between them.
2. Docker uses the client-server (C/S) architecture mode, and uses remote API to manage and create Docker containers

(2) Core concepts (from the rookie tutorial)

1. Image: The image packaged by the software, that is, the source code for building the container, is a read-only template and placed in the docker warehouse. 2. Container
: The instance after the image is started is called a container, and the container It is an application or a group of applications that run independently and are isolated from each other.
3. Repository: used to store packaged image files

Guess you like

Origin blog.csdn.net/qq_36737803/article/details/100727988