Docker装置

体系信息
[root@localhost yum.repos.d]# cat /etc/centos-release
CentOS Linux release 7.8.2003 (Core)
[root@localhost yum.repos.d]# uname -a
Linux localhost.localdomain 3.10.0-514.el7.x86_64 #1 SMP Tue Nov 22 16:42:41 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
[root@localhost yum.repos.d]#

装置docker
1、装置yum扩展东西
yum install -y yum-utils (yum-utils的作用是办理repository及扩展包的东西,增加 repo 文件)

2、增加docker源
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
[root@localhost yum.repos.d]# ls -l
总用量 40
-rw-r--r--. 1 root root 1664 4月 8 06:01 CentOS-Base.repo
-rw-r--r--. 1 root root 1309 4月 8 06:01 CentOS-CR.repo
-rw-r--r--. 1 root root 649 4月 8 06:01 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root 314 4月 8 06:01 CentOS-fasttrack.repo
-rw-r--r--. 1 root root 630 4月 8 06:01 CentOS-Media.repo
-rw-r--r--. 1 root root 1331 4月 8 06:01 CentOS-Sources.repo
-rw-r--r--. 1 root root 7577 4月 8 06:01 CentOS-Vault.repo
-rw-r--r--. 1 root root 616 4月 8 06:01 CentOS-x86_64-kernel.repo
-rw-r--r--. 1 root root 2424 10月 19 2019 docker-ce.repo #多了一个文件
[root@localhost yum.repos.d]#

3、装置docker-ce
yum install docker-ce docker-ce-cli containerd.io

##yum list docker-ce --showduplicates | sort -r 检查能装置的版别
##yum install docker-ce-<VERSION_STRING> docker-ce-cli-<VERSION_STRING> containerd.i 装置指定版别

4、发动docker
systemctl start docker 发动docker

5、验证docker
docker run hello-world 输出一个

[root@localhost yum.repos.d]# ps -ef |grep docker
root 28579 2176 0 19:01 pts/0 00:00:00 grep --color=auto docker
[root@localhost yum.repos.d]# systemctl start docker
[root@localhost yum.repos.d]# ps -ef |grep docker
root 28589 1 2 19:01 ? 00:00:00 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
root 28713 2176 0 19:01 pts/0 00:00:00 grep --color=auto docker
[root@localhost yum.repos.d]# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
0e03bdcc26d7: Pull complete
Digest: sha256:6a65f928fb91fcfbc963f7aa6d57c8eeb426ad9a20c7ee045538ef34847f44f1
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:

  1. The Docker client contacted the Docker daemon.
  2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
  3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
  4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/

For more examples and ideas, visit:
https://docs.docker.com/get-started/

6、输出以上内容证明docker装置成功