王大拿
知道的越多,不知道的也就越多! 只要学不死,就往死里学!!!
随笔 - 118,  文章 - 1,  评论 - 7,  阅读 - 82255

(参考学习:狂神说Docker)

1Docker docker 概述

1.1Docker为什么会出现?

1.1.1面临的问题:

  1. 我在我的电脑上能运行,为什么到你的电脑就不能用;
  2. 版本更新,导致服务不可用;
  3. 对于运维来说,考验十分大;
  4. 环境配置十分麻烦,每个环境都要部署环境(集群Redis、ES、Hadoop..)!费时费力;
  5. 发布一个项目(jar +(redis + mysql + jdk + es)),配置超级麻烦,项目能不能都带上安装环境打包发布;
  6. 配置一个应用的环境Redis mysql jdk ES Hadoop,配置十分麻烦,不能够跨平台。

java -- apk -- 发布(应用商店)-- 张三使用apk -- 下载安装即可用
Java -- jar(环境)--打包项目带上环境(镜像)---(docker仓库:商店)--下载发布的镜像 --直接运行就行;

1.1.2Docker给以上问题,提出了解决方案

image
Docker的思想来自于集装箱
Docker 属于 Linux 容器的一种封装,提供简单易用的容器使用接口。;
Docker 将应用程序与该程序的依赖,打包在一个文件里面。运行这个文件,就会生成一个虚拟容器。程序在这个虚拟容器里运行,就好像在真实的物理机上运行一样。
容器除了运行其中应用外,基本不消耗额外的系统资源,使得应用的性能很高,同时系统的开销尽量小。传统虚拟机方式运行 5个不同的应用就要起 5 个虚拟机,而Docker 只需要启动5个隔离的应用即可。
image

2. Docker安装

2.1.Docker安装的前提条件

2.1.1.操作系统要求

要安装 Docker 引擎,您需要 CentOS 7 或 8 的维护版本
uname -r

image

2.1.2.卸载旧版本

旧版本的 Docker 被称为docker或docker-engine。如果安装了这些,请卸载它们以及相关的依赖项。
卸载操作

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

image

2.2安装方法

您可以根据需要以不同方式安装 Docker Engine:
大多数用户 设置 Docker 的存储库并从中安装,以便于安装和升级任务。这是推荐的方法。
一些用户下载 RPM 包并 手动安装并完全手动管理升级。这在诸如在无法访问互联网的气隙系统上安装 Docker 等情况下非常有用。
在测试和开发环境中,一些用户选择使用自动化的 便捷脚本来安装 Docker。
在新主机上首次安装 Docker Engine 之前,您需要设置 Docker 存储库。之后,您可以从存储库安装和更新 Docker。

2.2.1设置存储库

2.2.1.1安装yum-utils包

yum install -y yum-utils

[root@centos-8:~]$ yum install -y yum-utils
上次元数据过期检查:0:10:55 前,执行于 2021年07月19日 星期一 04时56分42秒。
依赖关系解决。
=========================================================================================================================
 软件包                                  架构                  版本                          仓库                   大小
=========================================================================================================================
安装:
 yum-utils                               noarch                4.0.18-4.el8                  baseos                 71 k
升级:
 dnf-plugins-core                        noarch                4.0.18-4.el8                  baseos                 69 k
 python3-dnf-plugins-core                noarch                4.0.18-4.el8                  baseos                234 k

事务概要
=========================================================================================================================
安装  1 软件包
升级  2 软件包

总下载:375 k
下载软件包:
(1/3): dnf-plugins-core-4.0.18-4.el8.noarch.rpm                                          240 kB/s |  69 kB     00:00
(2/3): yum-utils-4.0.18-4.el8.noarch.rpm                                                 245 kB/s |  71 kB     00:00
(3/3): python3-dnf-plugins-core-4.0.18-4.el8.noarch.rpm                                  533 kB/s | 234 kB     00:00    
-------------------------------------------------------------------------------------------------------------------------
总计                                                                                     246 kB/s | 375 kB     00:01
运行事务检查
事务检查成功。
运行事务测试
事务测试成功。
运行事务
  准备中  :                                                                                                          1/1 
  升级    : python3-dnf-plugins-core-4.0.18-4.el8.noarch                                                             1/5 
  升级    : dnf-plugins-core-4.0.18-4.el8.noarch                                                                     2/5 
  安装    : yum-utils-4.0.18-4.el8.noarch                                                                            3/5 
  清理    : dnf-plugins-core-4.0.17-5.el8.noarch                                                                     4/5 
  清理    : python3-dnf-plugins-core-4.0.17-5.el8.noarch                                                             5/5 
  运行脚本: python3-dnf-plugins-core-4.0.17-5.el8.noarch                                                             5/5 
  验证    : yum-utils-4.0.18-4.el8.noarch                                                                            1/5 
  验证    : dnf-plugins-core-4.0.18-4.el8.noarch                                                                     2/5 
  验证    : dnf-plugins-core-4.0.17-5.el8.noarch                                                                     3/5 
  验证    : python3-dnf-plugins-core-4.0.18-4.el8.noarch                                                             4/5 
  验证    : python3-dnf-plugins-core-4.0.17-5.el8.noarch                                                             5/5 

已升级:
  dnf-plugins-core-4.0.18-4.el8.noarch                    python3-dnf-plugins-core-4.0.18-4.el8.noarch

已安装:
  yum-utils-4.0.18-4.el8.noarch

完毕!

2.2.1.2设置稳定存储库

yum-config-manager \
    --add-repo \
    https://download.docker.com/linux/centos/docker-ce.repo

image

2.2.1.3安装 Docker 引擎

通过完全限定的包名称安装特定版本,即包名称 ( docker-ce) 加上从第一个冒号 ( :)开始的版本字符串(第 2 列),直到第一个连字符,由连字符 ( -)分隔。例如,docker-ce-18.09.1。
yum install docker-ce-<VERSION_STRING> docker-ce-cli-<VERSION_STRING> containerd.io

2.2.1.3.1安装特定版本的 Docker Engine,在 repo 中列出可用版本,然后选择并安装

yum list docker-ce --showduplicates | sort -r

image

2.2.1.3.2安装最新版本

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

如果提示接受 GPG 密钥,请验证指纹是否匹配060A 61C5 1B55 8A7F 742B 77AA C52F EB6B 621E 9F35,如果匹配 ,请接受。

[root@centos-8:~]$ yum install docker-ce docker-ce-cli containerd.io
上次元数据过期检查:0:11:16 前,执行于 2021年07月19日 星期一 05时08分49秒。
依赖关系解决。
=========================================================================================================================
 软件包                            架构        版本                                          仓库                   大小
=========================================================================================================================
安装:
 containerd.io                     x86_64      1.4.6-3.1.el8                                 docker-ce-stable       34 M
 docker-ce                         x86_64      3:20.10.7-3.el8                               docker-ce-stable       27 M
 docker-ce-cli                     x86_64      1:20.10.7-3.el8                               docker-ce-stable       33 M
升级:
 libsemanage                       x86_64      2.9-6.el8                                     baseos                165 k
 policycoreutils                   x86_64      2.9-14.el8                                    baseos                373 k
安装依赖关系:
 checkpolicy                       x86_64      2.9-1.el8                                     baseos                348 k
 container-selinux                 noarch      2:2.162.0-1.module_el8.4.0+830+8027e1c4       appstream              52 k
 docker-ce-rootless-extras         x86_64      20.10.7-3.el8                                 docker-ce-stable      9.2 M
 docker-scan-plugin                x86_64      0.8.0-3.el8                                   docker-ce-stable      4.2 M
 fuse-overlayfs                    x86_64      1.4.0-3.module_el8.4.0+830+8027e1c4           appstream              72 k
 fuse3                             x86_64      3.2.1-12.el8                                  baseos                 50 k
 fuse3-libs                        x86_64      3.2.1-12.el8                                  baseos                 94 k
 libcgroup                         x86_64      0.41-19.el8                                   baseos                 70 k
 libslirp                          x86_64      4.3.1-1.module_el8.4.0+575+63b40ad7           appstream              69 k
 policycoreutils-python-utils      noarch      2.9-14.el8                                    baseos                252 k
 python3-audit                     x86_64      3.0-0.17.20191104git1c2f876.el8               baseos                 86 k
 python3-libsemanage               x86_64      2.9-6.el8                                     baseos                127 k
 python3-policycoreutils           noarch      2.9-14.el8                                    baseos                2.2 M
 python3-setools                   x86_64      4.3.0-2.el8                                   baseos                626 k
 slirp4netns                       x86_64      1.1.8-1.module_el8.4.0+641+6116a774           appstream              51 k
启用模块流:
 container-tools                               rhel8

事务概要
=========================================================================================================================
安装  18 软件包
升级   2 软件包

总下载:111 M
确定吗?[y/N]: y
下载软件包:
(1/20): container-selinux-2.162.0-1.module_el8.4.0+830+8027e1c4.noarch.rpm               222 kB/s |  52 kB     00:00
(2/20): libslirp-4.3.1-1.module_el8.4.0+575+63b40ad7.x86_64.rpm                          291 kB/s |  69 kB     00:00
(3/20): fuse-overlayfs-1.4.0-3.module_el8.4.0+830+8027e1c4.x86_64.rpm                    267 kB/s |  72 kB     00:00
(4/20): slirp4netns-1.1.8-1.module_el8.4.0+641+6116a774.x86_64.rpm                       679 kB/s |  51 kB     00:00
(5/20): fuse3-3.2.1-12.el8.x86_64.rpm                                                    641 kB/s |  50 kB     00:00
(6/20): fuse3-libs-3.2.1-12.el8.x86_64.rpm                                               869 kB/s |  94 kB     00:00
(7/20): libcgroup-0.41-19.el8.x86_64.rpm                                                 794 kB/s |  70 kB     00:00
(8/20): checkpolicy-2.9-1.el8.x86_64.rpm                                                 1.2 MB/s | 348 kB     00:00
(9/20): python3-audit-3.0-0.17.20191104git1c2f876.el8.x86_64.rpm                         724 kB/s |  86 kB     00:00    
(10/20): policycoreutils-python-utils-2.9-14.el8.noarch.rpm                              1.1 MB/s | 252 kB     00:00
(11/20): python3-libsemanage-2.9-6.el8.x86_64.rpm                                        906 kB/s | 127 kB     00:00
(12/20): python3-setools-4.3.0-2.el8.x86_64.rpm                                          1.3 MB/s | 626 kB     00:00
(13/20): python3-policycoreutils-2.9-14.el8.noarch.rpm                                   1.6 MB/s | 2.2 MB     00:01
(14/20): containerd.io-1.4.6-3.1.el8.x86_64.rpm                                          612 kB/s |  34 MB     00:56
(15/20): docker-ce-rootless-extras-20.10.7-3.el8.x86_64.rpm                              1.6 MB/s | 9.2 MB     00:05
(16/20): docker-ce-20.10.7-3.el8.x86_64.rpm                                              442 kB/s |  27 MB     01:01
(17/20): libsemanage-2.9-6.el8.x86_64.rpm                                                304 kB/s | 165 kB     00:00
(18/20): policycoreutils-2.9-14.el8.x86_64.rpm                                           1.0 MB/s | 373 kB     00:00
(19/20): docker-scan-plugin-0.8.0-3.el8.x86_64.rpm                                       1.4 MB/s | 4.2 MB     00:02
(20/20): docker-ce-cli-20.10.7-3.el8.x86_64.rpm                                          471 kB/s |  33 MB     01:12
-------------------------------------------------------------------------------------------------------------------------
总计                                                                                     1.5 MB/s | 111 MB     01:15     
警告:/var/cache/dnf/docker-ce-stable-fa9dc42ab4cec2f4/packages/containerd.io-1.4.6-3.1.el8.x86_64.rpm: 头V4 RSA/SHA512 Signature, 密钥 ID 621e9f35: NOKEY
Docker CE Stable - x86_64                                                                1.6 kB/s | 1.6 kB     00:00
导入 GPG 公钥 0x621E9F35:
 Userid: "Docker Release (CE rpm) <docker@docker.com>"
 指纹: 060A 61C5 1B55 8A7F 742B 77AA C52F EB6B 621E 9F35
 来自: https://download.docker.com/linux/centos/gpg
确定吗?[y/N]: y
导入公钥成功
运行事务检查
事务检查成功。
运行事务测试
事务测试成功。
运行事务
  准备中  :                                                                                                          1/1 
  运行脚本: docker-scan-plugin-0.8.0-3.el8.x86_64                                                                    1/1 
  安装    : docker-scan-plugin-0.8.0-3.el8.x86_64                                                                   1/22 
  运行脚本: docker-scan-plugin-0.8.0-3.el8.x86_64                                                                   1/22 
  安装    : docker-ce-cli-1:20.10.7-3.el8.x86_64                                                                    2/22 
  运行脚本: docker-ce-cli-1:20.10.7-3.el8.x86_64                                                                    2/22 
  升级    : libsemanage-2.9-6.el8.x86_64                                                                            3/22 
  升级    : policycoreutils-2.9-14.el8.x86_64                                                                       4/22 
  运行脚本: policycoreutils-2.9-14.el8.x86_64                                                                       4/22 
  安装    : python3-libsemanage-2.9-6.el8.x86_64                                                                    5/22 
  安装    : python3-setools-4.3.0-2.el8.x86_64                                                                      6/22 
  安装    : python3-audit-3.0-0.17.20191104git1c2f876.el8.x86_64                                                    7/22 
  运行脚本: libcgroup-0.41-19.el8.x86_64                                                                            8/22 
  安装    : libcgroup-0.41-19.el8.x86_64                                                                            8/22 
  运行脚本: libcgroup-0.41-19.el8.x86_64                                                                            8/22 
  安装    : fuse3-libs-3.2.1-12.el8.x86_64                                                                          9/22 
  运行脚本: fuse3-libs-3.2.1-12.el8.x86_64                                                                          9/22 
  安装    : fuse3-3.2.1-12.el8.x86_64                                                                              10/22 
  安装    : fuse-overlayfs-1.4.0-3.module_el8.4.0+830+8027e1c4.x86_64                                              11/22 
  运行脚本: fuse-overlayfs-1.4.0-3.module_el8.4.0+830+8027e1c4.x86_64                                              11/22 
  安装    : checkpolicy-2.9-1.el8.x86_64                                                                           12/22 
  安装    : python3-policycoreutils-2.9-14.el8.noarch                                                              13/22 
  安装    : policycoreutils-python-utils-2.9-14.el8.noarch                                                         14/22 
  运行脚本: container-selinux-2:2.162.0-1.module_el8.4.0+830+8027e1c4.noarch                                       15/22 
  安装    : container-selinux-2:2.162.0-1.module_el8.4.0+830+8027e1c4.noarch                                       15/22 
  运行脚本: container-selinux-2:2.162.0-1.module_el8.4.0+830+8027e1c4.noarch                                       15/22 
  安装    : containerd.io-1.4.6-3.1.el8.x86_64                                                                     16/22 
  运行脚本: containerd.io-1.4.6-3.1.el8.x86_64                                                                     16/22 
  安装    : libslirp-4.3.1-1.module_el8.4.0+575+63b40ad7.x86_64                                                    17/22 
  安装    : slirp4netns-1.1.8-1.module_el8.4.0+641+6116a774.x86_64                                                 18/22 
  安装    : docker-ce-rootless-extras-20.10.7-3.el8.x86_64                                                         19/22 
  运行脚本: docker-ce-rootless-extras-20.10.7-3.el8.x86_64                                                         19/22 
  安装    : docker-ce-3:20.10.7-3.el8.x86_64                                                                       20/22 
  运行脚本: docker-ce-3:20.10.7-3.el8.x86_64                                                                       20/22 
  运行脚本: policycoreutils-2.9-9.el8.x86_64                                                                       21/22 
  清理    : policycoreutils-2.9-9.el8.x86_64                                                                       21/22 
  清理    : libsemanage-2.9-3.el8.x86_64                                                                           22/22 
  运行脚本: container-selinux-2:2.162.0-1.module_el8.4.0+830+8027e1c4.noarch                                       22/22 
  运行脚本: libsemanage-2.9-3.el8.x86_64                                                                           22/22 
  验证    : container-selinux-2:2.162.0-1.module_el8.4.0+830+8027e1c4.noarch                                        1/22 
  验证    : fuse-overlayfs-1.4.0-3.module_el8.4.0+830+8027e1c4.x86_64                                               2/22 
  验证    : libslirp-4.3.1-1.module_el8.4.0+575+63b40ad7.x86_64                                                     3/22 
  验证    : slirp4netns-1.1.8-1.module_el8.4.0+641+6116a774.x86_64                                                  4/22 
  验证    : checkpolicy-2.9-1.el8.x86_64                                                                            5/22 
  验证    : fuse3-3.2.1-12.el8.x86_64                                                                               6/22 
  验证    : fuse3-libs-3.2.1-12.el8.x86_64                                                                          7/22 
  验证    : libcgroup-0.41-19.el8.x86_64                                                                            8/22 
  验证    : policycoreutils-python-utils-2.9-14.el8.noarch                                                          9/22 
  验证    : python3-audit-3.0-0.17.20191104git1c2f876.el8.x86_64                                                   10/22 
  验证    : python3-libsemanage-2.9-6.el8.x86_64                                                                   11/22 
  验证    : python3-policycoreutils-2.9-14.el8.noarch                                                              12/22 
  验证    : python3-setools-4.3.0-2.el8.x86_64                                                                     13/22 
  验证    : containerd.io-1.4.6-3.1.el8.x86_64                                                                     14/22 
  验证    : docker-ce-3:20.10.7-3.el8.x86_64                                                                       15/22 
  验证    : docker-ce-cli-1:20.10.7-3.el8.x86_64                                                                   16/22 
  验证    : docker-ce-rootless-extras-20.10.7-3.el8.x86_64                                                         17/22 
  验证    : docker-scan-plugin-0.8.0-3.el8.x86_64                                                                  18/22 
  验证    : libsemanage-2.9-6.el8.x86_64                                                                           19/22 
  验证    : libsemanage-2.9-3.el8.x86_64                                                                           20/22 
  验证    : policycoreutils-2.9-14.el8.x86_64                                                                      21/22 
  验证    : policycoreutils-2.9-9.el8.x86_64                                                                       22/22 

已升级:
  libsemanage-2.9-6.el8.x86_64                             policycoreutils-2.9-14.el8.x86_64

已安装:
  checkpolicy-2.9-1.el8.x86_64                       container-selinux-2:2.162.0-1.module_el8.4.0+830+8027e1c4.noarch
  containerd.io-1.4.6-3.1.el8.x86_64                 docker-ce-3:20.10.7-3.el8.x86_64
  docker-ce-cli-1:20.10.7-3.el8.x86_64               docker-ce-rootless-extras-20.10.7-3.el8.x86_64
  docker-scan-plugin-0.8.0-3.el8.x86_64              fuse-overlayfs-1.4.0-3.module_el8.4.0+830+8027e1c4.x86_64
  fuse3-3.2.1-12.el8.x86_64                          fuse3-libs-3.2.1-12.el8.x86_64
  libcgroup-0.41-19.el8.x86_64                       libslirp-4.3.1-1.module_el8.4.0+575+63b40ad7.x86_64
  policycoreutils-python-utils-2.9-14.el8.noarch     python3-audit-3.0-0.17.20191104git1c2f876.el8.x86_64
  python3-libsemanage-2.9-6.el8.x86_64               python3-policycoreutils-2.9-14.el8.noarch
  python3-setools-4.3.0-2.el8.x86_64                 slirp4netns-1.1.8-1.module_el8.4.0+641+6116a774.x86_64

完毕!

2.3启动 Docker

systemctl start docker
[root@centos-8:~]$ systemctl start docker

2.4查看当前docker的版本信息

[root@centos-8:~]$ docker version

Client: Docker Engine - Community
 Version:           20.10.7
 API version:       1.41
 Go version:        go1.13.15
 Git commit:        f0df350
 Built:             Wed Jun  2 11:56:24 2021
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.7
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.13.15
  Git commit:       b0f5bc3
  Built:            Wed Jun  2 11:54:48 2021
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.4.6
  GitCommit:        d71fcd7d8303cbf684402823e425e9dd2e99285d
 runc:
  Version:          1.0.0-rc95
  GitCommit:        b9ee9c6314599f1b4a7f497e1f1f856fe433d3b7
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

[root@centos-8:~]$ docker info

Client:
 Context:    default
 Debug Mode: false
 Plugins:
  app: Docker App (Docker Inc., v0.9.1-beta3)
  buildx: Build with BuildKit (Docker Inc., v0.5.1-docker)
  scan: Docker Scan (Docker Inc., v0.8.0)

Server:
 Containers: 0
  Running: 0
  Paused: 0
  Stopped: 0
 Images: 0
 Server Version: 20.10.7
 Storage Driver: overlay2
  Backing Filesystem: xfs
  Supports d_type: true
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 1
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: d71fcd7d8303cbf684402823e425e9dd2e99285d
 runc version: b9ee9c6314599f1b4a7f497e1f1f856fe433d3b7
 init version: de40ad0
 Security Options:
  seccomp
   Profile: default
 Kernel Version: 4.18.0-240.el8.x86_64
 Operating System: CentOS Linux 8
 OSType: linux
 Architecture: x86_64
 CPUs: 4
 Total Memory: 1.748GiB
 Name: centos-8.3
 ID: BPPN:CR2K:CRFL:MUJZ:H6EO:4VOA:E4RE:25M4:QA2B:ZEHM:XJJP:J4KC
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

[root@centos-8:~]$ docker --help

Usage:  docker [OPTIONS] COMMAND

A self-sufficient runtime for containers

Options:
      --config string      Location of client config files (default "/root/.docker")
  -c, --context string     Name of the context to use to connect to the daemon (overrides DOCKER_HOST env var and
                           default context set with "docker context use")
  -D, --debug              Enable debug mode
  -H, --host list          Daemon socket(s) to connect to
  -l, --log-level string   Set the logging level ("debug"|"info"|"warn"|"error"|"fatal") (default "info")
      --tls                Use TLS; implied by --tlsverify
      --tlscacert string   Trust certs signed only by this CA (default "/root/.docker/ca.pem")
      --tlscert string     Path to TLS certificate file (default "/root/.docker/cert.pem")
      --tlskey string      Path to TLS key file (default "/root/.docker/key.pem")
      --tlsverify          Use TLS and verify the remote
  -v, --version            Print version information and quit

Management Commands:
  app*        Docker App (Docker Inc., v0.9.1-beta3)
  builder     Manage builds
  buildx*     Build with BuildKit (Docker Inc., v0.5.1-docker)
  config      Manage Docker configs
  container   Manage containers
  context     Manage contexts
  image       Manage images
  manifest    Manage Docker image manifests and manifest lists
  network     Manage networks
  node        Manage Swarm nodes
  plugin      Manage plugins
  scan*       Docker Scan (Docker Inc., v0.8.0)
  secret      Manage Docker secrets
  service     Manage services
  stack       Manage Docker stacks
  swarm       Manage Swarm
  system      Manage Docker
  trust       Manage trust on Docker images
  volume      Manage volumes

Commands:
  attach      Attach local standard input, output, and error streams to a running container
  build       Build an image from a Dockerfile
  commit      Create a new image from a container's changes
  cp          Copy files/folders between a container and the local filesystem
  create      Create a new container
  diff        Inspect changes to files or directories on a container's filesystem
  events      Get real time events from the server
  exec        Run a command in a running container
  export      Export a container's filesystem as a tar archive
  history     Show the history of an image
  images      List images
  import      Import the contents from a tarball to create a filesystem image
  info        Display system-wide information
  inspect     Return low-level information on Docker objects
  kill        Kill one or more running containers
  load        Load an image from a tar archive or STDIN
  login       Log in to a Docker registry
  logout      Log out from a Docker registry
  logs        Fetch the logs of a container
  pause       Pause all processes within one or more containers
  port        List port mappings or a specific mapping for the container
  ps          List containers
  pull        Pull an image or a repository from a registry
  push        Push an image or a repository to a registry
  rename      Rename a container
  restart     Restart one or more containers
  rm          Remove one or more containers
  rmi         Remove one or more images
  run         Run a command in a new container
  save        Save one or more images to a tar archive (streamed to STDOUT by default)
  search      Search the Docker Hub for images
  start       Start one or more stopped containers
  stats       Display a live stream of container(s) resource usage statistics
  stop        Stop one or more running containers
  tag         Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
  top         Display the running processes of a container
  unpause     Unpause all processes within one or more containers
  update      Update configuration of one or more containers
  version     Show the Docker version information
  wait        Block until one or more containers stop, then print their exit codes

Run 'docker COMMAND --help' for more information on a command.

To get more help with docker, check out our guides at https://docs.docker.com/go/guides/

2.5阿里云docker镜像加速器

image
image
检查镜像仓库加速器是否配置成功

通过运行hello-world 映像验证 Docker Engine 是否已正确安装

[root@centos-8:~]$ docker run hello-world

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
b8dfde127a29: Pull complete 
latest: Pulling from library/hello-world
b8dfde127a29: Already exists 
Digest: sha256:df5f5184104426b65967e016ff2ac0bfcd44ad7899ca3bbcf8e44e4461491a9e
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/

image

image

2.6设置开机自启动

[root@centos-8:~]$systemctl enable docker
Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /usr/lib/systemd/system/docker.service.

3.建立docker 用户组

3.1建立docker组

[root@centos-8:~]# groupadd docker
groupadd: group 'docker' already exists

3.2将当前用户加入docker组

[root@centos-8:~]#usermod -aG docker $USER

4.容器命令

5.镜像命令

操作命令

Docker 镜像!

容器数据卷

DockerFile

Docker网络原理

posted on   DevOps_SRE  阅读(237)  评论(0编辑  收藏  举报
编辑推荐:
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 张高兴的大模型开发实战:(一)使用 Selenium 进行网页爬虫
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示