(2022版)一套教程搞定k8s安装到实战 | Docker基本命令

Posted COCOgsta

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了(2022版)一套教程搞定k8s安装到实战 | Docker基本命令相关的知识,希望对你有一定的参考价值。

视频来源:B站《(2022版)最新、最全、最详细的Kubernetes(K8s)教程,从K8s安装到实战一套搞定》

一边学习一边整理老师的课程内容及试验笔记,并与大家分享,侵权即删,谢谢支持!

附上汇总贴:(2022版)一套教程搞定k8s安装到实战 | 汇总_COCOgsta的博客-CSDN博客


[root@k8s-master01 ~]# docker version
Client: Docker Engine - Community
 Version:           20.10.17
 API version:       1.40
 Go version:        go1.17.11
 Git commit:        100c701
 Built:             Mon Jun  6 23:05:12 2022
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          19.03.15
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.13.15
  Git commit:       99e3ed8919
  Built:            Sat Jan 30 03:16:33 2021
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.6
  GitCommit:        10c12954828e7c7c9b6e0ea9b0c02b01407d3ae1
 runc:
  Version:          1.1.2
  GitCommit:        v1.1.2-0-ga916309
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683
[root@k8s-master01 ~]# 
[root@k8s-master01 ~]# docker info
Client:
 Context:    default
 Debug Mode: false
 Plugins:
  app: Docker App (Docker Inc., v0.9.1-beta3)
  buildx: Docker Buildx (Docker Inc., v0.8.2-docker)
WARNING: Plugin "/usr/libexec/docker/cli-plugins/docker-scan" is not valid: failed to fetch metadata: fork/exec /usr/libexec/docker/cli-plugins/docker-scan: exec format error

Server:
 Containers: 10
  Running: 4
  Paused: 0
  Stopped: 6
 Images: 5
 Server Version: 19.03.15
 Storage Driver: devicemapper # aufs、overlay brtfs
  Pool Name: docker-253:0-3035967-pool
  Pool Blocksize: 65.54kB
  Base Device Size: 10.74GB
  Backing Filesystem: xfs
  Udev Sync Supported: true
  Data file: /dev/loop0
  Metadata file: /dev/loop1
  Data loop file: /var/lib/docker/devicemapper/devicemapper/data
  Metadata loop file: /var/lib/docker/devicemapper/devicemapper/metadata
  Data Space Used: 619.4MB
  Data Space Total: 107.4GB
  Data Space Available: 10.63GB
  Metadata Space Used: 18.56MB
  Metadata Space Total: 2.147GB
  Metadata Space Available: 2.129GB
  Thin Pool Minimum Free Space: 10.74GB
  Deferred Removal Enabled: true
  Deferred Deletion Enabled: true
  Deferred Deleted Device Count: 0
  Library Version: 1.02.170-RHEL7 (2020-03-24)
 Logging Driver: json-file # json-file存在本地
 Cgroup Driver: systemd
 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: runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 10c12954828e7c7c9b6e0ea9b0c02b01407d3ae1
 runc version: v1.1.2-0-ga916309
 init version: fec3683
 Security Options:
  seccomp
   Profile: default
 Kernel Version: 4.19.12-1.el7.elrepo.x86_64
 Operating System: CentOS Linux 7 (Core)
 OSType: linux
 Architecture: x86_64
 CPUs: 2
 Total Memory: 1.923GiB
 Name: k8s-master01
 ID: PPTJ:RXWD:5IWS:62IC:2GP4:RKI7:R233:3RGW:D6LN:4IXW:WUUZ:NJHR
 Docker Root Dir: /var/lib/docker # 可以更改的,ssd的硬盘,最好使用一个单独的磁盘进行挂载
 Debug Mode: false
 Registry: https://index.docker.io/v1/ # hub.docker.com
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

WARNING: the devicemapper storage-driver is deprecated, and will be removed in a future release.
WARNING: devicemapper: usage of loopback devices is strongly discouraged for production use.
         Use `--storage-opt dm.thinpooldev` to specify a custom block storage device.
[root@k8s-master01 ~]# 
[root@k8s-master01 ~]# docker search centos
NAME                                         DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
centos                                       The official build of CentOS.                   7199      [OK]       
centos/systemd                               systemd enabled base container.                 108                  [OK]
centos/mysql-57-centos7                      MySQL 5.7 SQL database server                   95                   
kasmweb/centos-7-desktop                     CentOS 7 desktop for Kasm Workspaces            21                   
centos/mongodb-36-centos7                    MongoDB NoSQL database server                   8                    
kasmweb/core-centos-7                        CentOS 7 base image for Kasm Workspaces         3                    
continuumio/centos5_gcc5_base                                                                3                    
couchbase/centos7-systemd                    centos7-systemd images with additional debug…   1                    [OK]
spack/centos7                                CentOS 7 with Spack preinstalled                1                    
spack/centos-stream                                                                          0                    
couchbase/centos-72-jenkins-core                                                             0                    
fnndsc/centos-python3                        Source for a slim Centos-based Python3 image…   0                    [OK]
couchbase/centos-72-java-sdk                                                                 0                    
couchbase/centos-69-sdk-build                                                                0                    
couchbase/centos-70-sdk-build                                                                0                    
datadog/centos-i386                                                                          0                    
spack/centos6                                CentOS 6 with Spack preinstalled                0                    
starlingx/stx-centos                         StarlingX centos                                0                    
ibmcom/fhe-toolkit-centos-amd64              The IBM Fully Homomorphic Encryption (FHE) T…   0                    
ibmcom/fhe-toolkit-centos                    The IBM Fully Homomorphic Encryption (FHE) T…   0                    
apache/couchdbci-centos                      Apache CouchDB CI CentOS                        0                    
silintl/openldap                             OpenLDAP base image on Centos 6                 0                    [OK]
bitnami/centos-extras-base                                                                   0                    
bitnami/centos-base-buildpack                Centos base compilation image                   0                    [OK]
couchbase/centos-69-sdk-nodevtoolset-build                                                   0                    
[root@k8s-master01 ~]# docker search nginx
NAME                                              DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
nginx                                             Official build of Nginx.                        16983     [OK]       
linuxserver/nginx                                 An Nginx container, brought to you by LinuxS…   169                  
bitnami/nginx                                     Bitnami nginx Docker Image                      131                  [OK]
ubuntu/nginx                                      Nginx, a high-performance reverse proxy & we…   52                   
bitnami/nginx-ingress-controller                  Bitnami Docker Image for NGINX Ingress Contr…   18                   [OK]
rancher/nginx-ingress-controller                                                                  10                   
clearlinux/nginx                                  Nginx reverse proxy server with the benefits…   4                    
ibmcom/nginx-ingress-controller                   Docker Image for IBM Cloud Private-CE (Commu…   4                    
bitnami/nginx-ldap-auth-daemon                                                                    3                    
rancher/nginx                                                                                     2                    
bitnami/nginx-exporter                                                                            2                    
vmware/nginx                                                                                      2                    
rancher/nginx-ingress-controller-defaultbackend                                                   2                    
circleci/nginx                                    This image is for internal use                  2                    
vmware/nginx-photon                                                                               1                    
rapidfort/nginx                                   RapidFort optimized, hardened image for NGINX   1                    
wallarm/nginx-ingress-controller                  Kubernetes Ingress Controller with Wallarm e…   1                    
bitnami/nginx-intel                                                                               1                    
kasmweb/nginx                                     An Nginx image based off nginx:alpine and in…   1                    
rancher/nginx-conf                                                                                0                    
ibmcom/nginx-ingress-controller-ppc64le           Docker Image for IBM Cloud Private-CE (Commu…   0                    
continuumio/nginx-ingress-ws                                                                      0                    
rancher/nginx-ingress-controller-amd64                                                            0                    
ibmcom/nginx-ppc64le                              Docker image for nginx-ppc64le                  0                    
rancher/nginx-ssl                                                                                 0                    
[root@k8s-master01 ~]# 
[root@k8s-master01 ~]# docker pull alpine:latest # 本地若有镜像不会重复拉取
latest: Pulling from library/alpine
2408cc74d12b: Pull complete 
Digest: sha256:686d8c9dfa6f3ccfc8230bc3178d23f84eeaf7e457f36f271ab1acc53015037c
Status: Downloaded newer image for alpine:latest
docker.io/library/alpine:latest
You have new mail in /var/spool/mail/root
[root@k8s-master01 ~]# 
[root@k8s-master01 ~]# docker tag alpine:latest guolianggsta/alpine:latest
[root@k8s-master01 ~]# docker tag alpine:latest guolianggsta/alpine:latest
jConfigure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

Login Succeeded
[root@k8s-master01 ~]# 
[root@k8s-master01 ~]# docker push guolianggsta/alpine:latest
The push refers to repository [docker.io/guolianggsta/alpine]
24302eb7d908: Mounted from library/alpine 
latest: digest: sha256:4ff3ca91275773af45cb4b0834e12b7eb47d1c18f770a0b151381cd227f4c253 size: 528
[root@k8s-master01 ~]# 
[root@k8s-master01 ~]# docker run -it alpine:latest  sh
/ # 
/ # 
/ # 
/ # 

[root@k8s-master01 ~]# docker run -it nginx:1.14.2 sh
Unable to find image 'nginx:1.14.2' locally
1.14.2: Pulling from library/nginx
27833a3ba0a5: Pull complete 
0f23e58bd0b7: Pull complete 
8ca774778e85: Pull complete 
Digest: sha256:f7988fb6c02e0ce69257d9bd9cf37ae20a60f1df7563c3a2a6abe24160306b8d
Status: Downloaded newer image for nginx:1.14.2
# 
# 

[root@k8s-master01 ~]# docker run -d nginx:1.14.2 sh # -d表示后台启动一个进程
f3925ab212784ce86d350776d3b0daca2688f0a0edf28ff621d1cfe7528e04b9
[root@k8s-master01 ~]# 
[root@k8s-master01 ~]# docker logs -f b1aa9b735420
"level":"info","msg":"Kubernetes host: https://10.96.0.1:443","time":"2022-06-23T02:13:21Z"
192.168.1.107 - - [23/Jun/2022:02:13:52 +0000] "GET / HTTP/1.1" 200 6 "" "kube-probe/1.20"
192.168.1.107 - - [23/Jun/2022:02:14:02 +0000] "GET / HTTP/1.1" 200 6 "" "kube-probe/1.20"
192.168.1.107 - - [23/Jun/2022:02:14:12 +0000] "GET / HTTP/1.1" 200 6 "" "kube-probe/1.20"
"level":"info","msg":"Database updated: 5 nodes, 10 pods","time":"2022-06-23T02:14:21Z"
192.168.1.107 - - [23/Jun/2022:02:14:22 +0000] "GET / HTTP/1.1" 200 6 "" "kube-probe/1.20"
172.25.92.64 - - [23/Jun/2022:02:14:24 +0000] "GET /healthz HTTP/1.1" 200 13 "" "dashboard/v2.0.4"
192.168.1.107 - - [23/Jun/2022:02:14:32 +0000] "GET / HTTP/1.1" 200 6 "" "kube-probe/1.20"
192.168.1.107 - - [23/Jun/2022:02:14:42 +0000] "GET / HTTP/1.1" 200 6 "" "kube-probe/1.20"
192.168.1.107 - - [23/Jun/2022:02:14:52 +0000] "GET / HTTP/1.1" 200 6 "" "kube-probe/1.20"
172.25.92.64 - - [23/Jun/2022:02:14:54 +0000] "GET /healthz HTTP/1.1" 200 13 "" "dashboard/v2.0.4"
192.168.1.107 - - [23/Jun/2022:02:15:02 +0000] "GET / HTTP/1.1" 200 6 "" "kube-probe/1.20"
192.168.1.107 - - [23/Jun/2022:02:15:12 +0000] "GET / HTTP/1.1" 200 6 "" "kube-probe/1.20"
"level":"info","msg":"Database updated: 5 nodes, 10 pods","time":"2022-06-23T02:15:21Z"
192.168.1.107 - - [23/Jun/2022:02:15:22 +0000] "GET / HTTP/1.1" 200 6 "" "kube-probe/1.20"
172.25.92.64 - - [23/Jun/2022:02:15:24 +0000] "GET /healthz HTTP/1.1" 200 13 "" "dashboard/v2.0.4"
192.168.1.107 - - [23/Jun/2022:02:15:32 +0000] "GET / HTTP/1.1" 200 6 "" "kube-probe/1.20"
192.168.1.107 - - [23/Jun/2022:02:15:42 +0000] "GET / HTTP/1.1" 200 6 "" "kube-probe/1.20"
[root@k8s-master01 ~]# docker ps
CONTAINER ID   IMAGE                                                                 COMMAND              CREATED        STATUS        PORTS     NAMES
b1aa9b735420   86262685d9ab                                                          "/metrics-sidecar"   24 hours ago   Up 24 hours             k8s_dashboard-metrics-scraper_dashboard-metrics-scraper-7645f69d8c-92hzc_kubernetes-dashboard_b5bd764b-b520-4450-99d9-aac6c55e8316_1
646932befa6a   registry.cn-hangzhou.aliyuncs.com/google_containers/pause-amd64:3.2   "/pause"             24 hours ago   Up 24 hours             k8s_POD_dashboard-metrics-scraper-7645f69d8c-92hzc_kubernetes-dashboard_b5bd764b-b520-4450-99d9-aac6c55e8316_2
27a98fe675fc   d45bf977dfbf                                                          "start_runit"        24 hours ago   Up 24 hours             k8s_calico-node_calico-node-tstnv_kube-system_9f4ae917-7448-4a99-aca2-f7126c768a0a_1
2bcad372e77e   registry.cn-hangzhou.aliyuncs.com/google_containers/pause-amd64:3.2   "/pause"             24 hours ago   Up 24 hours             k8s_POD_calico-node-tstnv_kube-system_9f4ae917-7448-4a99-aca2-f7126c768a0a_1
[root@k8s-master01 ~]# 
[root@k8s-master01 ~]# 
[root@k8s-master01 ~]# docker ps -a
CONTAINER ID   IMAGE                                                                 COMMAND                  CREATED          STATUS                      PORTS     NAMES
f3925ab21278   nginx:1.14.2                                                          "sh"                     20 minutes ago   Exited (0) 20 minutes ago             optimistic_joliot
dc89f8fb24c8   nginx:1.14.2                                                          "sh"                     22 minutes ago   Exited (0) 20 minutes ago             sleepy_borg
04cd7a480254   alpine:latest                                                         "sh"                     24 minutes ago   Exited (0) 23 minutes ago             adoring_faraday
d99c0a30c82c   alpine:latest                                                         "bash"                   24 minutes ago   Created                               distracted_khorana
b1aa9b735420   86262685d9ab                                                          "/metrics-sidecar"       24 hours ago     Up 24 hours                           k8s_dashboard-metrics-scraper_dashboard-metrics-scraper-7645f69d8c-92hzc_kubernetes-dashboard_b5bd764b-b520-4450-99d9-aac6c55e8316_1
646932befa6a   registry.cn-hangzhou.aliyuncs.com/google_containers/pause-amd64:3.2   "/pause"                 24 hours ago     Up 24 hours                           k8s_POD_dashboard-metrics-scraper-7645f69d8c-92hzc_kubernetes-dashboard_b5bd764b-b520-4450-99d9-aac6c55e8316_2
27a98fe675fc   d45bf977dfbf                                                          "start_runit"            24 hours ago     Up 24 hours                           k8s_calico-node_calico-node-tstnv_kube-system_9f4ae917-7448-4a99-aca2-f7126c768a0a_1
ec82192edef4   963564fb95ed                                                          "/usr/local/bin/flex…"   24 hours ago     Exited (0) 24 hours ago               k8s_flexvol-driver_calico-node-tstnv_kube-system_9f4ae917-7448-4a99-aca2-f7126c768a0a_0
ab63d540576f   ca5564c06ea0                                                          "/install-cni.sh"        24 hours ago     Exited (0) 24 hours ago               k8s_install-cni_calico-node-tstnv_kube-system_9f4ae917-7448-4a99-aca2-f7126c768a0a_1
2bcad372e77e   registry.cn-hangzhou.aliyuncs.com/google_containers/pause-amd64:3.2   "/pause"                 24 hours ago     Up 24 hours                           k8s_POD_calico-node-tstnv_kube-system_9f4ae917-7448-4a99-aca2-f7126c768a0a_1
6b91d896f94c   registry.cn-beijing.aliyuncs.com/dotbalo/metrics-scraper              "/metrics-sidecar"       44 hours ago     Exited (2) 24 hours ago               k8s_dashboard-metrics-scraper_dashboard-metrics-scraper-7645f69d8c-92hzc_kubernetes-dashboard_b5bd764b-b520-4450-99d9-aac6c55e8316_0
f15b45ac36ef   registry.cn-hangzhou.aliyuncs.com/google_containers/pause-amd64:3.2   "/pause"                 44 hours ago     Exited (0) 24 hours ago               k8s_POD_dashboard-metrics-scraper-7645f69d8c-92hzc_kubernetes-dashboard_b5bd764b-b520-4450-99d9-aac6c55e8316_0
e56fca8267fa   registry.cn-beijing.aliyuncs.com/dotbalo/node                         "start_runit"            47 hours ago     Exited (0) 24 hours ago               k8s_calico-node_calico-node-tstnv_kube-system_9f4ae917-7448-4a99-aca2-f7126c768a0a_0
dc9471add10b   registry.cn-hangzhou.aliyuncs.com/google_containers/pause-amd64:3.2   "/pause"                 47 hours ago     Exited (0) 24 hours ago               k8s_POD_calico-node-tstnv_kube-system_9f4ae917-7448-4a99-aca2-f7126c768a0a_0
[root@k8s-master01 ~]# 
[root@k8s-master01 ~]# 
[root@k8s-master01 ~]# docker ps -q
b1aa9b735420
646932befa6a
27a98fe675fc
2bcad372e77e
[root@k8s-master01 ~]# 
[root@k8s-master01 ~]# 
[root@k8s-master01 ~]# docker ps -qa
f3925ab21278
dc89f8fb24c8
04cd7a480254
d99c0a30c82c
b1aa9b735420
646932befa6a
27a98fe675fc
ec82192edef4
ab63d540576f
2bcad372e77e
6b91d896f94c
f15b45ac36ef
e56fca8267fa
dc9471add10b
[root@k8s-master01 ~]# 
[root@k8s-master01 ~]# docker exec -it  27a98fe675fc bash
[root@k8s-master01 /]# 
[root@k8s-master01 /]# 
[root@k8s-master01 /]# ls
@System.solv  bin  boot  calico-secrets  dev  etc  home  included-source  lib  lib64  licenses  lost+found  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var
[root@k8s-master01 /]# 
[root@k8s-master01 ~]# echo "test cp" > index.html
[root@k8s-master01 ~]# 
[root@k8s-master01 ~]# ls
anaconda-ks.cfg                  index.html            k8s-ha-install                             kernel-ml-devel-4.19.12-1.el7.elrepo.x86_64.rpm
etcd-v3.4.13-linux-amd64.tar.gz  initial-setup-ks.cfg  kernel-ml-4.19.12-1.el7.elrepo.x86_64.rpm  kubernetes-server-linux-amd64.tar.gz
[root@k8s-master01 ~]# docker cp index.html 6f7256e24436:/usr/share/nginx/html/
[root@k8s-master01 ~]# 
[root@k8s-master01 ~]# docker cp 6f7256e24436:/usr/share/nginx/html/index.html .
[root@k8s-master01 ~]# 
[root@k8s-master01 ~]# docker ps -a
CONTAINER ID   IMAGE                                                                 COMMAND                  CREATED          STATUS                      PORTS                   NAMES
6f7256e24436   nginx:1.14.2                                                          "nginx -g 'daemon of…"   4 minutes ago    Up 4 minutes                0.0.0.0:12345->80/tcp   keen_mccarthy
f3925ab21278   nginx:1.14.2                                                          "sh"                     35 minutes ago   Exited (0) 35 minutes ago                           optimistic_joliot
dc89f8fb24c8   nginx:1.14.2                                                          "sh"                     38 minutes ago   Exited (0) 36 minutes ago                           sleepy_borg
04cd7a480254   alpine:latest                                                         "sh"                     39 minutes ago   Exited (0) 39 minutes ago                           adoring_faraday
d99c0a30c82c   alpine:latest                                                         "bash"                   40 minutes ago   Created                                             distracted_khorana
b1aa9b735420   86262685d9ab                                                          "/metrics-sidecar"       24 hours ago     Up 24 hours                                         k8s_dashboard-metrics-scraper_dashboard-metrics-scraper-7645f69d8c-92hzc_kubernetes-dashboard_b5bd764b-b520-4450-99d9-aac6c55e8316_1
646932befa6a   registry.cn-hangzhou.aliyuncs.com/google_containers/pause-amd64:3.2   "/pause"                 24 hours ago     Up 24 hours                                         k8s_POD_dashboard-metrics-scraper-7645f69d8c-92hzc_kubernetes-dashboard_b5bd764b-b520-4450-99d9-aac6c55e8316_2
27a98fe675fc   d45bf977dfbf                                                          "start_runit"            24 hours ago     Up 24 hours                                         k8s_calico-node_calico-node-tstnv_kube-system_9f4ae917-7448-4a99-aca2-f7126c768a0a_1
ec82192edef4   963564fb95ed                                                          "/usr/local/bin/flex…"   24 hours ago     Exited (0) 24 hours ago                             k8s_flexvol-driver_calico-node-tstnv_kube-system_9f4ae917-7448-4a99-aca2-f7126c768a0a_0
ab63d540576f   ca5564c06ea0                                                          "/install-cni.sh"        24 hours ago     Exited (0) 24 hours ago                             k8s_install-cni_calico-node-tstnv_kube-system_9f4ae917-7448-4a99-aca2-f7126c768a0a_1
2bcad372e77e   registry.cn-hangzhou.aliyuncs.com/google_containers/pause-amd64:3.2   "/pause"                 24 hours ago     Up 24 hours                                         k8s_POD_calico-node-tstnv_kube-system_9f4ae917-7448-4a99-aca2-f7126c768a0a_1
6b91d896f94c   registry.cn-beijing.aliyuncs.com/dotbalo/metrics-scraper              "/metrics-sidecar"       44 hours ago     Exited (2) 24 hours ago                             k8s_dashboard-metrics-scraper_dashboard-metrics-scraper-7645f69d8c-92hzc_kubernetes-dashboard_b5bd764b-b520-4450-99d9-aac6c55e8316_0
f15b45ac36ef   registry.cn-hangzhou.aliyuncs.com/google_containers/pause-amd64:3.2   "/pause"                 44 hours ago     Exited (0) 24 hours ago                             k8s_POD_dashboard-metrics-scraper-7645f69d8c-92hzc_kubernetes-dashboard_b5bd764b-b520-4450-99d9-aac6c55e8316_0
e56fca8267fa   registry.cn-beijing.aliyuncs.com/dotbalo/node                         "start_runit"            2 days ago       Exited (0) 24 hours ago                             k8s_calico-node_calico-node-tstnv_kube-system_9f4ae917-7448-4a99-aca2-f7126c768a0a_0
dc9471add10b   registry.cn-hangzhou.aliyuncs.com/google_containers/pause-amd64:3.2   "/pause"                 2 days ago       Exited (0) 24 hours ago                             k8s_POD_calico-node-tstnv_kube-system_9f4ae917-7448-4a99-aca2-f7126c768a0a_0
[root@k8s-master01 ~]# 
[root@k8s-master01 ~]# docker rm f3925ab21278
f3925ab21278
[root@k8s-master01 ~]# docker images
REPOSITORY                                                        TAG       IMAGE ID       CREATED         SIZE
guolianggsta/alpine                                               latest    e66264b98777   4 weeks ago     5.52MB
alpine                                                            latest    e66264b98777   4 weeks ago     5.52MB
registry.cn-beijing.aliyuncs.com/dotbalo/node                     v3.15.3   d45bf977dfbf   21 months ago   262MB
registry.cn-beijing.aliyuncs.com/dotbalo/pod2daemon-flexvol       v3.15.3   963564fb95ed   21 months ago   22.8MB
registry.cn-beijing.aliyuncs.com/dotbalo/cni                      v3.15.3   ca5564c06ea0   21 months ago   110MB
registry.cn-beijing.aliyuncs.com/dotbalo/metrics-scraper          v1.0.4    86262685d9ab   2 years ago     36.9MB
registry.cn-hangzhou.aliyuncs.com/google_containers/pause-amd64   3.2       80d28bedfe5d   2 years ago     683kB
nginx                                                             1.14.2    295c7be07902   3 years ago     109MB
[root@k8s-master01 ~]# docker rmi guolianggsta/alpine
Untagged: guolianggsta/alpine:latest
Untagged: guolianggsta/alpine@sha256:4ff3ca91275773af45cb4b0834e12b7eb47d1c18f770a0b151381cd227f4c253
[root@k8s-master01 ~]# 
[root@k8s-master01 ~]# docker ps
CONTAINER ID   IMAGE                                                                 COMMAND                  CREATED         STATUS         PORTS                   NAMES
6f7256e24436   nginx:1.14.2                                                          "nginx -g 'daemon of…"   6 minutes ago   Up 6 minutes   0.0.0.0:12345->80/tcp   keen_mccarthy
b1aa9b735420   86262685d9ab                                                          "/metrics-sidecar"       24 hours ago    Up 24 hours                            k8s_dashboard-metrics-scraper_dashboard-metrics-scraper-7645f69d8c-92hzc_kubernetes-dashboard_b5bd764b-b520-4450-99d9-aac6c55e8316_1
646932befa6a   registry.cn-hangzhou.aliyuncs.com/google_containers/pause-amd64:3.2   "/pause"                 24 hours ago    Up 24 hours                            k8s_POD_dashboard-metrics-scraper-7645f69d8c-92hzc_kubernetes-dashboard_b5bd764b-b520-4450-99d9-aac6c55e8316_2
27a98fe675fc   d45bf977dfbf                                                          "start_runit"            24 hours ago    Up 24 hours                            k8s_calico-node_calico-node-tstnv_kube-system_9f4ae917-7448-4a99-aca2-f7126c768a0a_1
2bcad372e77e   registry.cn-hangzhou.aliyuncs.com/google_containers/pause-amd64:3.2   "/pause"                 24 hours ago    Up 24 hours                            k8s_POD_calico-node-tstnv_kube-system_9f4ae917-7448-4a99-aca2-f7126c768a0a_1
[root@k8s-master01 ~]# 
[root@k8s-master01 ~]# docker stop 6f7256e24436
6f7256e24436
[root@k8s-master01 ~]# docker ps
CONTAINER ID   IMAGE                                                                 COMMAND              CREATED        STATUS        PORTS     NAMES
b1aa9b735420   86262685d9ab                                                          "/metrics-sidecar"   24 hours ago   Up 24 hours             k8s_dashboard-metrics-scraper_dashboard-metrics-scraper-7645f69d8c-92hzc_kubernetes-dashboard_b5bd764b-b520-4450-99d9-aac6c55e8316_1
646932befa6a   registry.cn-hangzhou.aliyuncs.com/google_containers/pause-amd64:3.2   "/pause"             24 hours ago   Up 24 hours             k8s_POD_dashboard-metrics-scraper-7645f69d8c-92hzc_kubernetes-dashboard_b5bd764b-b520-4450-99d9-aac6c55e8316_2
27a98fe675fc   d45bf977dfbf                                                          "start_runit"        24 hours ago   Up 24 hours             k8s_calico-node_calico-node-tstnv_kube-system_9f4ae917-7448-4a99-aca2-f7126c768a0a_1
2bcad372e77e   registry.cn-hangzhou.aliyuncs.com/google_containers/pause-amd64:3.2   "/pause"             24 hours ago   Up 24 hours             k8s_POD_calico-node-tstnv_kube-system_9f4ae917-7448-4a99-aca2-f7126c768a0a_1
[root@k8s-master01 ~]# 
[root@k8s-master01 ~]# docker start 6f7256e24436
6f7256e24436
[root@k8s-master01 ~]# docker ps 
CONTAINER ID   IMAGE                                                                 COMMAND                  CREATED         STATUS         PORTS                   NAMES
6f7256e24436   nginx:1.14.2                                                          "nginx -g 'daemon of…"   7 minutes ago   Up 7 seconds   0.0.0.0:12345->80/tcp   keen_mccarthy
b1aa9b735420   86262685d9ab                                                          "/metrics-sidecar"       24 hours ago    Up 24 hours                            k8s_dashboard-metrics-scraper_dashboard-metrics-scraper-7645f69d8c-92hzc_kubernetes-dashboard_b5bd764b-b520-4450-99d9-aac6c55e8316_1
646932befa6a   registry.cn-hangzhou.aliyuncs.com/google_containers/pause-amd64:3.2   "/pause"                 24 hours ago    Up 24 hours                            k8s_POD_dashboard-metrics-scraper-7645f69d8c-92hzc_kubernetes-dashboard_b5bd764b-b520-4450-99d9-aac6c55e8316_2
27a98fe675fc   d45bf977dfbf                                                          "start_runit"            24 hours ago    Up 24 hours                            k8s_calico-node_calico-node-tstnv_kube-system_9f4ae917-7448-4a99-aca2-f7126c768a0a_1
2bcad372e77e   registry.cn-hangzhou.aliyuncs.com/google_containers/pause-amd64:3.2   "/pause"                 24 hours ago    Up 24 hours                            k8s_POD_calico-node-tstnv_kube-system_9f4ae917-7448-4a99-aca2-f7126c768a0a_1
[root@k8s-master01 ~]# 
[root@k8s-master01 ~]# docker history alpine
IMAGE          CREATED       CREATED BY                                      SIZE      COMMENT
e66264b98777   4 weeks ago   /bin/sh -c #(nop)  CMD ["/bin/sh"]              0B        
<missing>      4 weeks ago   /bin/sh -c #(nop) ADD file:8e81116368669ed3d…   5.52MB    
[root@k8s-master01 ~]# 
[root@k8s-master01 ~]# docker ps
CONTAINER ID   IMAGE                                                                 COMMAND                  CREATED         STATUS         PORTS                   NAMES
6f7256e24436   nginx:1.14.2                                                          "nginx -g 'daemon of…"   9 minutes ago   Up 2 minutes   0.0.0.0:12345->80/tcp   keen_mccarthy
b1aa9b735420   86262685d9ab                                                          "/metrics-sidecar"       24 hours ago    Up 24 hours                            k8s_dashboard-metrics-scraper_dashboard-metrics-scraper-7645f69d8c-92hzc_kubernetes-dashboard_b5bd764b-b520-4450-99d9-aac6c55e8316_1
646932befa6a   registry.cn-hangzhou.aliyuncs.com/google_containers/pause-amd64:3.2   "/pause"                 24 hours ago    Up 24 hours                            k8s_POD_dashboard-metrics-scraper-7645f69d8c-92hzc_kubernetes-dashboard_b5bd764b-b520-4450-99d9-aac6c55e8316_2
27a98fe675fc   d45bf977dfbf                                                          "start_runit"            24 hours ago    Up 24 hours                            k8s_calico-node_calico-node-tstnv_kube-system_9f4ae917-7448-4a99-aca2-f7126c768a0a_1
2bcad372e77e   registry.cn-hangzhou.aliyuncs.com/google_containers/pause-amd64:3.2   "/pause"                 24 hours ago    Up 24 hours                            k8s_POD_calico-node-tstnv_kube-system_9f4ae917-7448-4a99-aca2-f7126c768a0a_1
[root@k8s-master01 ~]# 
[root@k8s-master01 ~]# 
[root@k8s-master01 ~]# docker cp index.html 6f7256e24436:/usr/share/nginx/html/
[root@k8s-master01 ~]# 
[root@k8s-master01 ~]# docker commit -a "guolianggsta" -m "add index.html" 6f7256e24436 nginx:commit
sha256:029ceeabb47df6459ce0745b691a2ef1477e3627ff3371ccffd481534ebe6c47
[root@k8s-master01 ~]# 
[root@k8s-master01 ~]# 
[root@k8s-master01 ~]# docker run -it --rm nginx:commit bash
root@bab55273616f:/# cd /usr/share/nginx/html/
root@bab55273616f:/usr/share/nginx/html# ls
50x.html  index.html
root@bab55273616f:/usr/share/nginx/html# ls -l
total 8
-rw-r--r-- 1 root root 537 Dec  4  2018 50x.html
-rw-r--r-- 1 root root   8 Jun 24 02:32 index.html
root@bab55273616f:/usr/share/nginx/html# 

docker build在之后的课程讲解

以上是关于(2022版)一套教程搞定k8s安装到实战 | Docker基本命令的主要内容,如果未能解决你的问题,请参考以下文章

(2022版)一套教程搞定k8s安装到实战 | InitContainer

(2022版)一套教程搞定k8s安装到实战 | HPA

(2022版)一套教程搞定k8s安装到实战 | DaemonSet

(2022版)一套教程搞定k8s安装到实战 | Volumes

(2022版)一套教程搞定k8s安装到实战 | Cronjob

(2022版)一套教程搞定k8s安装到实战 | Pod