docker的扫盲-基本常识

本文详细介绍了Docker的基础知识,包括其概念、官网、架构和安装过程。在Linux环境中,通过yum安装Docker,并展示了启动、停止、重启Docker服务的命令。此外,还列举了Docker镜像和容器的常用操作,如拉取、删除镜像,创建、启动、停止、删除容器等。最后,对比了Docker与虚拟机的区别。
摘要由CSDN通过智能技术生成

一 docker

1.1 docker

1.docker是可以让开发者将其开发的应用打成包或者依赖包,放到一个轻量级、可移植的容器中,然后部署到任何linux服务器上。

1.2 docker发布的官网

2.官网:http://www.docker.com

1.3 docker的架构

1.4  docker的安装

vm中安装docker_健康平安的活着的专栏-CSDN博客

 1.5 docker 常用命令

启动docker:systemctl  start   docker

停止docker:systemctl stop docker

重启docker:systemctl restart docker

查看docker状态:systemctl status docker

设置开启自启动:system enable docker

 1.6 docker 镜像常用命令

镜像可以理解为要安装操作的软件包;

1.查看镜像

docker  images

docker images -q    #查看所有镜像的id

2.搜索镜像

docker  search  镜像名称   # 如  docker  search   redis

3.拉取镜像

docker pull  镜像名称     #如 docker pull redis   ;(不写版本号,默认为lastest)

下载具体的版本的镜像,如: docker pull mysql:5.7.29

[root@localhost docker-demo]# docker pull mysql:5.7.29
Trying to pull repository docker.io/library/mysql ... 
5.7.29: Pulling from docker.io/library/mysql
54fec2fa59d0: Pull complete 
bcc6c6145912: Pull complete 
951c3d959c9d: Pull complete 
05de4d0e206e: Pull complete 
319f0394ef42: Pull complete 
d9185034607b: Pull complete 
013a9c64dadc: Pull complete 
58b7b840ebff: Pull complete 
9b85c0abc43d: Pull complete 
bdf022f63e85: Pull complete 
35f7f707ce83: Pull complete 
Digest: sha256:95b4bc7c1b111906fdb7a39cd990dd99f21c594722735d059769b80312eb57a7
Status: Downloaded newer image for docker.io/mysql:5.7.29
[root@localhost docker-demo]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
docker.io/mysql     5.7.29              5d9483f9a7b2        19 months ago       455 MB
docker.io/tomcat    8.5.6               14b94bb71f89        5 years ago         333 MB

拉取tomcat:docker  pull  tomcat:8.5.6

4.删除镜像

docker  rmi  镜像的id

删除所有的镜像: docker rmi ·docker images -q·

 1.7 docker 的容器命令

1.创建容器

docker  run -it   --name=xx  xxx ; #如 docker  run -it  --name=c1  centos:7  ;     docker  run -id  --name=c1  centos:7  ;

docker run -it  xxxx;  # -i表示容器持续运行,-it表示容器创建完后,自动进入容器中,退出后,容器自动关闭。-t 为容器分配一个终端。

docker run -id xxx;# -id表示用后台守护进程的方式进行创建容器,并一直在后台进行运行。使用decker exec 进入容器,退出后,容器不会关闭。

                   -it 为交互式容器

                  -id 为守护式容器

               --name 为创建的容器的名字

#第一种方式,创建tomcat容器,直接进入容器中

 #第二种方式,创建容器

#第3种方式,创建python容器,直接进入容器中

docker run -d --name python5 -p 8000:8000 -v /root/dky-python-model/algorithm_service:/opt/python_algorithm_service/algorithm_service/algorithms python_algorithm_service:1.0_dky

-v  操作在容器创建的过程时候可以将宿主机的目录挂载到容器内。

其中所主机目录:/root/dky-python-model/algorithm_service

docker容器目录:/opt/python_algorithm_service/algorithm_service/algorithms python_algorithm_service

2.查看docker 容器的进程命令(在linux服务器中,非容器中执行

#查看正在运行容器进程的docker命令

docker ps    

#查看所有容器的进程

docker ps -a

3.进入docker 容器

docker exec -it 容器名称  /bin/bash   # 如 docker exec -it   c2   /bin/bash

[root@bogon ~]#  docker  run -id  --name=c2  tomcat:8.5.6
e5f59bb9fc585278fe7c7693a313a02b1ed3f4540683281691a616682565be1e
[root@bogon ~]# docker exec -it c2 /bin/bash
root@e5f59bb9fc58:/usr/local/tomcat# ls
LICENSE  NOTICE  RELEASE-NOTES    RUNNING.txt  bin  conf    include  lib  logs  native-jni-lib  temp  webapps  work
 

 4.关闭docker容器

docker  stop  容器id或者容器名称

5.删除容器

docker  rm   容器id或者容器名称

5.启动容器

docker  start   容器id或者容器名称

1.docker ps  
2.docker  ps  -a
3.docker   start   容器名称
4.docker exec -it  容器名称 /bin/bash
5.docker logs  容器id
6.docker rmi -f  镜像id
7.docker rm  -f   容器id

1.8 docker与虚拟机的区别

1.个人觉得,虚拟机更接近底层,容器在虚拟机之上。

docker具有轻量级,vm比较笨重;docker依赖宿主机的操作系统;vm可以安装多个操作系统

6.查看容器信息

docker  inspect  容器id或者容器名称

二 docker的安装

见本人的这篇博客

vm中安装docker_健康平安的活着的专栏-CSDN博客

2.1 yum 安装docker

输入:uname -r

然后输入: yum install  docker

根据提示,选择y即可。

[root@localhost ~]# uname -r
3.10.0-862.el7.x86_64
[root@localhost ~]# yum install docker
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.bupt.edu.cn
 * extras: mirrors.bupt.edu.cn
 * updates: mirrors.bupt.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package docker.x86_64 2:1.13.1-208.git7d71120.el7_9 will be installed
--> Processing Dependency: docker-common = 2:1.13.1-208.git7d71120.el7_9 for package: 2:docker-1.13.1-208.git7d71120.el7_9.x86_64
--> Processing Dependency: docker-client = 2:1.13.1-208.git7d71120.el7_9 for package: 2:docker-1.13.1-208.git7d71120.el7_9.x86_64
--> Processing Dependency: subscription-manager-rhsm-certificates for package: 2:docker-1.13.1-208.git7d71120.el7_9.x86_64
--> Running transaction check
---> Package docker-client.x86_64 2:1.13.1-208.git7d71120.el7_9 will be installed
---> Package docker-common.x86_64 2:1.13.1-208.git7d71120.el7_9 will be installed
--> Processing Dependency: skopeo-containers >= 1:0.1.26-2 for package: 2:docker-common-1.13.1-208.git7d71120.el7_9.x86_64
--> Processing Dependency: oci-umount >= 2:2.3.3-3 for package: 2:docker-common-1.13.1-208.git7d71120.el7_9.x86_64
--> Processing Dependency: oci-systemd-hook >= 1:0.1.4-9 for package: 2:docker-common-1.13.1-208.git7d71120.el7_9.x86_64
--> Processing Dependency: oci-register-machine >= 1:0-5.13 for package: 2:docker-common-1.13.1-208.git7d71120.el7_9.x86_64
--> Processing Dependency: container-storage-setup >= 0.9.0-1 for package: 2:docker-common-1.13.1-208.git7d71120.el7_9.x86_64
--> Processing Dependency: container-selinux >= 2:2.51-1 for package: 2:docker-common-1.13.1-208.git7d71120.el7_9.x86_64
--> Processing Dependency: atomic-registries for package: 2:docker-common-1.13.1-208.git7d71120.el7_9.x86_64
---> Package subscription-manager-rhsm-certificates.x86_64 0:1.24.48-1.el7.centos will be installed
--> Running transaction check
---> Package atomic-registries.x86_64 1:1.22.1-33.gitb507039.el7_8 will be installed
--> Processing Dependency: python-pytoml for package: 1:atomic-registries-1.22.1-33.gitb507039.el7_8.x86_64
---> Package container-selinux.noarch 2:2.119.2-1.911c772.el7_8 will be installed
--> Processing Dependency: selinux-policy-targeted >= 3.13.1-216.el7 for package: 2:container-selinux-2.119.2-1.911c772.el7_8.noarch
--> Processing Dependency: selinux-policy-base >= 3.13.1-216.el7 for package: 2:container-selinux-2.119.2-1.911c772.el7_8.noarch
--> Processing Dependency: selinux-policy >= 3.13.1-216.el7 for package: 2:container-selinux-2.119.2-1.911c772.el7_8.noarch
---> Package container-storage-setup.noarch 0:0.11.0-2.git5eaf76c.el7 will be installed
---> Package containers-common.x86_64 1:0.1.40-11.el7_8 will be installed
--> Processing Dependency: subscription-manager for package: 1:containers-common-0.1.40-11.el7_8.x86_64
--> Processing Dependency: slirp4netns for package: 1:containers-common-0.1.40-11.el7_8.x86_64
--> Processing Dependency: fuse-overlayfs for package: 1:containers-common-0.1.40-11.el7_8.x86_64
---> Package oci-register-machine.x86_64 1:0-6.git2b44233.el7 will be installed
---> Package oci-systemd-hook.x86_64 1:0.2.0-1.git05e6923.el7_6 will be installed
---> Package oci-umount.x86_64 2:2.5-3.el7 will be installed
--> Running transaction check
---> Package fuse-overlayfs.x86_64 0:0.7.2-6.el7_8 will be installed
--> Processing Dependency: libfuse3.so.3(FUSE_3.2)(64bit) for package: fuse-overlayfs-0.7.2-6.el7_8.x86_64
--> Processing Dependency: libfuse3.so.3(FUSE_3.0)(64bit) for package: fuse-overlayfs-0.7.2-6.el7_8.x86_64
--> Processing Dependency: libfuse3.so.3()(64bit) for package: fuse-overlayfs-0.7.2-6.el7_8.x86_64
---> Package python-pytoml.noarch 0:0.1.14-1.git7dea353.el7 will be installed
---> Package selinux-policy.noarch 0:3.13.1-192.el7 will be updated
---> Package selinux-policy.noarch 0:3.13.1-268.el7_9.2 will be an update
--> Processing Dependency: policycoreutils >= 2.5-24 for package: selinux-policy-3.13.1-268.el7_9.2.noarch
--> Processing Dependency: libsemanage >= 2.5-13 for package: selinux-policy-3.13.1-268.el7_9.2.noarch
---> Package selinux-policy-targeted.noarch 0:3.13.1-192.el7 will be updated
---> Package selinux-policy-targeted.noarch 0:3.13.1-268.el7_9.2 will be an update
---> Package slirp4netns.x86_64 0:0.4.3-4.el7_8 will be installed
---> Package subscription-manager.x86_64 0:1.24.48-1.el7.centos will be installed
--> Processing Dependency: subscription-manager-rhsm = 1.24.48 for package: subscription-manager-1.24.48-1.el7.centos.x86_64
--> Processing Dependency: python-syspurpose for package: subscription-manager-1.24.48-1.el7.centos.x86_64
--> Processing Dependency: python-dateutil for package: subscription-manager-1.24.48-1.el7.centos.x86_64
--> Running transaction check
---> Package fuse3-libs.x86_64 0:3.6.1-4.el7 will be installed
---> Package libsemanage.x86_64 0:2.5-11.el7 will be updated
--> Processing Dependency: libsemanage = 2.5-11.el7 for package: libsemanage-python-2.5-11.el7.x86_64
---> Package libsemanage.x86_64 0:2.5-14.el7 will be an update
--> Processing Dependency: libsepol >= 2.5-10 for package: libsemanage-2.5-14.el7.x86_64
--> Processing Dependency: libselinux >= 2.5-14 for package: libsemanage-2.5-14.el7.x86_64
---> Package policycoreutils.x86_64 0:2.5-22.el7 will be updated
--> Processing Dependency: policycoreutils = 2.5-22.el7 for package: policycoreutils-python-2.5-22.el7.x86_64
---> Package policycoreutils.x86_64 0:2.5-34.el7 will be an update
--> Processing Dependency: libselinux-utils >= 2.5-14 for package: policycoreutils-2.5-34.el7.x86_64
---> Package python-dateutil.noarch 0:1.5-7.el7 will be installed
---> Package python-syspurpose.x86_64 0:1.24.48-1.el7.centos will be installed
---> Package subscription-manager-rhsm.x86_64 0:1.24.48-1.el7.centos will be installed
--> Running transaction check
---> Package libselinux.x86_64 0:2.5-12.el7 will be updated
--> Processing Dependency: libselinux(x86-64) = 2.5-12.el7 for package: libselinux-python-2.5-12.el7.x86_64
---> Package libselinux.x86_64 0:2.5-15.el7 will be an update
---> Package libselinux-utils.x86_64 0:2.5-12.el7 will be updated
---> Package libselinux-utils.x86_64 0:2.5-15.el7 will be an update
---> Package libsemanage-python.x86_64 0:2.5-11.el7 will be updated
---> Package libsemanage-python.x86_64 0:2.5-14.el7 will be an update
---> Package libsepol.x86_64 0:2.5-8.1.el7 will be updated
---> Package libsepol.x86_64 0:2.5-10.el7 will be an update
---> Package policycoreutils-python.x86_64 0:2.5-22.el7 will be updated
---> Package policycoreutils-python.x86_64 0:2.5-34.el7 will be an update
--> Processing Dependency: setools-libs >= 3.3.8-4 for package: policycoreutils-python-2.5-34.el7.x86_64
--> Running transaction check
---> Package libselinux-python.x86_64 0:2.5-12.el7 will be updated
---> Package libselinux-python.x86_64 0:2.5-15.el7 will be an update
---> Package setools-libs.x86_64 0:3.3.8-2.el7 will be updated
---> Package setools-libs.x86_64 0:3.3.8-4.el7 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

==============================================================================
 Package                   Arch   Version                       Repository
                                                                         Size
==============================================================================
Installing:
 docker                    x86_64 2:1.13.1-208.git7d71120.el7_9 extras   17 M
Installing for dependencies:
 atomic-registries         x86_64 1:1.22.1-33.gitb507039.el7_8  extras   36 k
 container-selinux         noarch 2:2.119.2-1.911c772.el7_8     extras   40 k
 container-storage-setup   noarch 0.11.0-2.git5eaf76c.el7       extras   35 k
 containers-common         x86_64 1:0.1.40-11.el7_8             extras   43 k
 docker-client             x86_64 2:1.13.1-208.git7d71120.el7_9 extras  3.9 M
 docker-common             x86_64 2:1.13.1-208.git7d71120.el7_9 extras  101 k
 fuse-overlayfs            x86_64 0.7.2-6.el7_8                 extras   54 k
 fuse3-libs                x86_64 3.6.1-4.el7                   extras   82 k
 oci-register-machine      x86_64 1:0-6.git2b44233.el7          extras  1.1 M
 oci-systemd-hook          x86_64 1:0.2.0-1.git05e6923.el7_6    extras   34 k
 oci-umount                x86_64 2:2.5-3.el7                   extras   33 k
 python-dateutil           noarch 1.5-7.el7                     base     85 k
 python-pytoml             noarch 0.1.14-1.git7dea353.el7       extras   18 k
 python-syspurpose         x86_64 1.24.48-1.el7.centos          updates 274 k
 slirp4netns               x86_64 0.4.3-4.el7_8                 extras   81 k
 subscription-manager      x86_64 1.24.48-1.el7.centos          updates 1.1 M
 subscription-manager-rhsm x86_64 1.24.48-1.el7.centos          updates 333 k
 subscription-manager-rhsm-certificates
                           x86_64 1.24.48-1.el7.centos          updates 237 k
Updating for dependencies:
 libselinux                x86_64 2.5-15.el7                    base    162 k
 libselinux-python         x86_64 2.5-15.el7                    base    236 k
 libselinux-utils          x86_64 2.5-15.el7                    base    151 k
 libsemanage               x86_64 2.5-14.el7                    base    151 k
 libsemanage-python        x86_64 2.5-14.el7                    base    113 k
 libsepol                  x86_64 2.5-10.el7                    base    297 k
 policycoreutils           x86_64 2.5-34.el7                    base    917 k
 policycoreutils-python    x86_64 2.5-34.el7                    base    457 k
 selinux-policy            noarch 3.13.1-268.el7_9.2            updates 498 k
 selinux-policy-targeted   noarch 3.13.1-268.el7_9.2            updates 7.0 M
 setools-libs              x86_64 3.3.8-4.el7                   base    620 k

Transaction Summary
==============================================================================
Install  1 Package  (+18 Dependent packages)
Upgrade             ( 11 Dependent packages)

Total size: 35 M
Total download size: 25 M
Is this ok [y/d/N]: y
Downloading packages:
warning: /var/cache/yum/x86_64/7/extras/packages/atomic-registries-1.22.1-33.gitb507039.el7_8.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Public key for atomic-registries-1.22.1-33.gitb507039.el7_8.x86_64.rpm is not installed
(1/19): atomic-registries-1.22.1-33.gitb507039.el7_8.x86 |  36 kB   00:00     
(2/19): container-selinux-2.119.2-1.911c772.el7_8.noarch |  40 kB   00:00     
(3/19): containers-common-0.1.40-11.el7_8.x86_64.rpm     |  43 kB   00:00     
(4/19): container-storage-setup-0.11.0-2.git5eaf76c.el7. |  35 kB   00:00     
(5/19): docker-client-1.13.1-208.git7d71120.el7_9.x86_64 | 3.9 MB   00:00     
(6/19): fuse-overlayfs-0.7.2-6.el7_8.x86_64.rpm          |  54 kB   00:00     
(7/19): oci-register-machine-0-6.git2b44233.el7.x86_64.r | 1.1 MB   00:00     
(8/19): oci-umount-2.5-3.el7.x86_64.rpm                  |  33 kB   00:00     
(9/19): docker-common-1.13.1-208.git7d71120.el7_9.x86_64 | 101 kB   00:00     
Public key for python-dateutil-1.5-7.el7.noarch.rpm is not installed
(10/19): python-dateutil-1.5-7.el7.noarch.rpm            |  85 kB   00:00     
(11/19): fuse3-libs-3.6.1-4.el7.x86_64.rpm               |  82 kB   00:00     
docker-1.13.1-208.git7d71120.e FAILED                                          
http://mirror.lzu.edu.cn/centos/7.9.2009/extras/x86_64/Packages/docker-1.13.1-208.git7d71120.el7_9.x86_64.rpm: [Errno 14] curl#56 - "Recv failure: Connection reset by peer"
Trying other mirror.
(12/19): python-pytoml-0.1.14-1.git7dea353.el7.noarch.rp |  18 kB   00:00     
(13/19): slirp4netns-0.4.3-4.el7_8.x86_64.rpm            |  81 kB   00:00     
(14/19): oci-systemd-hook-0.2.0-1.git05e6923.el7_6.x86_6 |  34 kB   00:00     
Public key for python-syspurpose-1.24.48-1.el7.centos.x86_64.rpm is not installed
(15/19): python-syspurpose-1.24.48-1.el7.centos.x86_64.r | 274 kB   00:00     
(16/19): subscription-manager-rhsm-1.24.48-1.el7.centos. | 333 kB   00:00     
(17/19): subscription-manager-rhsm-certificates-1.24.48- | 237 kB   00:00     
(18/19): subscription-manager-1.24.48-1.el7.centos.x86_6 | 1.1 MB   00:00     
(19/19): docker-1.13.1-208.git7d71120.el7_9.x86_64.rpm   |  17 MB   00:00     
------------------------------------------------------------------------------
Total                                            9.8 MB/s |  25 MB  00:02     
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Importing GPG key 0xF4A80EB5:
 Userid     : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
 Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
 Package    : centos-release-7-5.1804.el7.centos.x86_64 (@anaconda)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
** Found 1 pre-existing rpmdb problem(s), 'yum check' output follows:
glib2-devel-2.54.2-2.el7.x86_64 has missing requires of pkgconfig(libpcre)
  Updating   : libsepol-2.5-10.el7.x86_64                                1/41 
  Updating   : libselinux-2.5-15.el7.x86_64                              2/41 
  Updating   : libsemanage-2.5-14.el7.x86_64                             3/41 
  Updating   : libselinux-utils-2.5-15.el7.x86_64                        4/41 
  Updating   : policycoreutils-2.5-34.el7.x86_64                         5/41 
  Updating   : selinux-policy-3.13.1-268.el7_9.2.noarch                  6/41 
  Installing : python-dateutil-1.5-7.el7.noarch                                                               7/41 
  Installing : subscription-manager-rhsm-certificates-1.24.48-1.el7.centos.x86_64                             8/41 
  Installing : subscription-manager-rhsm-1.24.48-1.el7.centos.x86_64                                          9/41 
  Updating   : selinux-policy-targeted-3.13.1-268.el7_9.2.noarch                                             10/41 
  Updating   : libsemanage-python-2.5-14.el7.x86_64                                                          11/41 
  Updating   : libselinux-python-2.5-15.el7.x86_64                                                           12/41 
  Installing : 1:oci-systemd-hook-0.2.0-1.git05e6923.el7_6.x86_64                                            13/41 
  Updating   : setools-libs-3.3.8-4.el7.x86_64                                                               14/41 
  Updating   : policycoreutils-python-2.5-34.el7.x86_64                                                      15/41 
  Installing : 2:container-selinux-2.119.2-1.911c772.el7_8.noarch                                            16/41 
  Installing : python-syspurpose-1.24.48-1.el7.centos.x86_64                                                 17/41 
  Installing : subscription-manager-1.24.48-1.el7.centos.x86_64                                              18/41 
  Installing : slirp4netns-0.4.3-4.el7_8.x86_64                                                              19/41 
  Installing : 1:oci-register-machine-0-6.git2b44233.el7.x86_64                                              20/41 
  Installing : fuse3-libs-3.6.1-4.el7.x86_64                                                                 21/41 
  Installing : fuse-overlayfs-0.7.2-6.el7_8.x86_64                                                           22/41 
  Installing : 1:containers-common-0.1.40-11.el7_8.x86_64                                                    23/41 
  Installing : python-pytoml-0.1.14-1.git7dea353.el7.noarch                                                  24/41 
  Installing : 1:atomic-registries-1.22.1-33.gitb507039.el7_8.x86_64                                         25/41 
  Installing : 2:oci-umount-2.5-3.el7.x86_64                                                                 26/41 
  Installing : container-storage-setup-0.11.0-2.git5eaf76c.el7.noarch                                        27/41 
  Installing : 2:docker-common-1.13.1-208.git7d71120.el7_9.x86_64                                            28/41 
  Installing : 2:docker-client-1.13.1-208.git7d71120.el7_9.x86_64                                            29/41 
  Installing : 2:docker-1.13.1-208.git7d71120.el7_9.x86_64                                                   30/41 
  Cleanup    : selinux-policy-targeted-3.13.1-192.el7.noarch                                                 31/41 
  Cleanup    : policycoreutils-python-2.5-22.el7.x86_64                                                      32/41 
  Cleanup    : selinux-policy-3.13.1-192.el7.noarch                                                          33/41 
  Cleanup    : policycoreutils-2.5-22.el7.x86_64                                                             34/41 
  Cleanup    : libselinux-utils-2.5-12.el7.x86_64                                                            35/41 
  Cleanup    : setools-libs-3.3.8-2.el7.x86_64                                                               36/41 
  Cleanup    : libselinux-python-2.5-12.el7.x86_64                                                           37/41 
  Cleanup    : libsemanage-python-2.5-11.el7.x86_64                                                          38/41 
  Cleanup    : libsemanage-2.5-11.el7.x86_64                                                                 39/41 
  Cleanup    : libselinux-2.5-12.el7.x86_64                                                                  40/41 
  Cleanup    : libsepol-2.5-8.1.el7.x86_64                                                                   41/41 
  Verifying  : 1:atomic-registries-1.22.1-33.gitb507039.el7_8.x86_64                                          1/41 
  Verifying  : fuse-overlayfs-0.7.2-6.el7_8.x86_64                                                            2/41 
  Verifying  : libselinux-2.5-15.el7.x86_64                                                                   3/41 
  Verifying  : 2:container-selinux-2.119.2-1.911c772.el7_8.noarch                                             4/41 
  Verifying  : container-storage-setup-0.11.0-2.git5eaf76c.el7.noarch                                         5/41 
  Verifying  : libselinux-python-2.5-15.el7.x86_64                                                            6/41 
  Verifying  : 1:containers-common-0.1.40-11.el7_8.x86_64                                                     7/41 
  Verifying  : selinux-policy-targeted-3.13.1-268.el7_9.2.noarch                                              8/41 
  Verifying  : subscription-manager-rhsm-certificates-1.24.48-1.el7.centos.x86_64                             9/41 
  Verifying  : python-dateutil-1.5-7.el7.noarch                                                              10/41 
  Verifying  : policycoreutils-2.5-34.el7.x86_64                                                             11/41 
  Verifying  : subscription-manager-rhsm-1.24.48-1.el7.centos.x86_64                                         12/41 
  Verifying  : 2:oci-umount-2.5-3.el7.x86_64                                                                 13/41 
  Verifying  : libselinux-utils-2.5-15.el7.x86_64                                                            14/41 
  Verifying  : policycoreutils-python-2.5-34.el7.x86_64                                                      15/41 
  Verifying  : python-pytoml-0.1.14-1.git7dea353.el7.noarch                                                  16/41 
  Verifying  : fuse3-libs-3.6.1-4.el7.x86_64                                                                 17/41 
  Verifying  : libsemanage-python-2.5-14.el7.x86_64                                                          18/41 
  Verifying  : 1:oci-systemd-hook-0.2.0-1.git05e6923.el7_6.x86_64                                            19/41 
  Verifying  : libsemanage-2.5-14.el7.x86_64                                                                 20/41 
  Verifying  : 1:oci-register-machine-0-6.git2b44233.el7.x86_64                                              21/41 
  Verifying  : libsepol-2.5-10.el7.x86_64                                                                    22/41 
  Verifying  : slirp4netns-0.4.3-4.el7_8.x86_64                                                              23/41 
  Verifying  : selinux-policy-3.13.1-268.el7_9.2.noarch                                                      24/41 
  Verifying  : 2:docker-common-1.13.1-208.git7d71120.el7_9.x86_64                                            25/41 
  Verifying  : 2:docker-1.13.1-208.git7d71120.el7_9.x86_64                                                   26/41 
  Verifying  : 2:docker-client-1.13.1-208.git7d71120.el7_9.x86_64                                            27/41 
  Verifying  : setools-libs-3.3.8-4.el7.x86_64                                                               28/41 
  Verifying  : python-syspurpose-1.24.48-1.el7.centos.x86_64                                                 29/41 
  Verifying  : subscription-manager-1.24.48-1.el7.centos.x86_64                                              30/41 
  Verifying  : libsemanage-python-2.5-11.el7.x86_64                                                          31/41 
  Verifying  : libsemanage-2.5-11.el7.x86_64                                                                 32/41 
  Verifying  : libselinux-python-2.5-12.el7.x86_64                                                           33/41 
  Verifying  : setools-libs-3.3.8-2.el7.x86_64                                                               34/41 
  Verifying  : policycoreutils-2.5-22.el7.x86_64                                                             35/41 
  Verifying  : libsepol-2.5-8.1.el7.x86_64                                                                   36/41 
  Verifying  : policycoreutils-python-2.5-22.el7.x86_64                                                      37/41 
  Verifying  : selinux-policy-targeted-3.13.1-192.el7.noarch                                                 38/41 
  Verifying  : selinux-policy-3.13.1-192.el7.noarch                                                          39/41 
  Verifying  : libselinux-2.5-12.el7.x86_64                                                                  40/41 
  Verifying  : libselinux-utils-2.5-12.el7.x86_64                                                            41/41 

Installed:
  docker.x86_64 2:1.13.1-208.git7d71120.el7_9                                                                      

Dependency Installed:
  atomic-registries.x86_64 1:1.22.1-33.gitb507039.el7_8                                                            
  container-selinux.noarch 2:2.119.2-1.911c772.el7_8                                                               
  container-storage-setup.noarch 0:0.11.0-2.git5eaf76c.el7                                                         
  containers-common.x86_64 1:0.1.40-11.el7_8                                                                       
  docker-client.x86_64 2:1.13.1-208.git7d71120.el7_9                                                               
  docker-common.x86_64 2:1.13.1-208.git7d71120.el7_9                                                               
  fuse-overlayfs.x86_64 0:0.7.2-6.el7_8                                                                            
  fuse3-libs.x86_64 0:3.6.1-4.el7                                                                                  
  oci-register-machine.x86_64 1:0-6.git2b44233.el7                                                                 
  oci-systemd-hook.x86_64 1:0.2.0-1.git05e6923.el7_6                                                               
  oci-umount.x86_64 2:2.5-3.el7                                                                                    
  python-dateutil.noarch 0:1.5-7.el7                                                                               
  python-pytoml.noarch 0:0.1.14-1.git7dea353.el7                                                                   
  python-syspurpose.x86_64 0:1.24.48-1.el7.centos                                                                  
  slirp4netns.x86_64 0:0.4.3-4.el7_8                                                                               
  subscription-manager.x86_64 0:1.24.48-1.el7.centos                                                               
  subscription-manager-rhsm.x86_64 0:1.24.48-1.el7.centos                                                          
  subscription-manager-rhsm-certificates.x86_64 0:1.24.48-1.el7.centos                                             

Dependency Updated:
  libselinux.x86_64 0:2.5-15.el7                      libselinux-python.x86_64 0:2.5-15.el7                       
  libselinux-utils.x86_64 0:2.5-15.el7                libsemanage.x86_64 0:2.5-14.el7                             
  libsemanage-python.x86_64 0:2.5-14.el7              libsepol.x86_64 0:2.5-10.el7                                
  policycoreutils.x86_64 0:2.5-34.el7                 policycoreutils-python.x86_64 0:2.5-34.el7                  
  selinux-policy.noarch 0:3.13.1-268.el7_9.2          selinux-policy-targeted.noarch 0:3.13.1-268.el7_9.2         
  setools-libs.x86_64 0:3.3.8-4.el7                  

Complete!
[root@localhost ~]# 

2.2  启动docker

[root@localhost ~]# systemctl start docker

2.3  查看版本

[root@localhost ~]# docker -v
Docker version 1.13.1, build 7d71120/1.13.1

2.4  查看状态

[root@localhost ~]# systemctl status docker
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
   Active: active (running) since Tue 2021-11-09 11:27:28 CST; 12s ago
     Docs: http://docs.docker.com
 Main PID: 48667 (dockerd-current)
    Tasks: 17
   CGroup: /system.slice/docker.service
           ├─48667 /usr/bin/dockerd-current --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current --...
           └─48672 /usr/bin/docker-containerd-current -l unix:///var/run/docker/libcontainerd/docker-containerd....

Nov 09 11:27:26 localhost.localdomain dockerd-current[48667]: time="2021-11-09T11:27:26.367062959+08:00" leve...72"
Nov 09 11:27:27 localhost.localdomain dockerd-current[48667]: time="2021-11-09T11:27:27.472549615+08:00" leve...ds"
Nov 09 11:27:27 localhost.localdomain dockerd-current[48667]: time="2021-11-09T11:27:27.473578115+08:00" leve...t."
Nov 09 11:27:27 localhost.localdomain dockerd-current[48667]: time="2021-11-09T11:27:27.507332757+08:00" leve...ue"
Nov 09 11:27:27 localhost.localdomain dockerd-current[48667]: time="2021-11-09T11:27:27.675394564+08:00" leve...ss"
Nov 09 11:27:28 localhost.localdomain dockerd-current[48667]: time="2021-11-09T11:27:28.109764512+08:00" leve...e."
Nov 09 11:27:28 localhost.localdomain dockerd-current[48667]: time="2021-11-09T11:27:28.181073485+08:00" leve...on"
Nov 09 11:27:28 localhost.localdomain dockerd-current[48667]: time="2021-11-09T11:27:28.181101815+08:00" leve...3.1
Nov 09 11:27:28 localhost.localdomain systemd[1]: Started Docker Application Container Engine.
Nov 09 11:27:28 localhost.localdomain dockerd-current[48667]: time="2021-11-09T11:27:28.185887195+08:00" leve...ck"
Hint: Some lines were ellipsized, use -l to show in full.


2.5  设置开机自启动

[root@localhost ~]# systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
[root@localhost ~]# 
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值