网络知识 科技 (2022版)一套教程搞定k8s安装到实战 | Docker基本命令

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

{"data":{"title":"(2022版)一套教程搞定k8s安装到实战 | Docker基本命令","abstract":"一边学习一边整理老师的课程内容及试验笔记,并与大家分享,侵权即删,谢谢支持!docker build在之后的课程讲解。","articleType":"article","itemId":"7112632278815359502","groupId":"7112632278815359502","groupSource":2,"isOriginal":false,"banComment":false,"publishTime":"2022-06-24 11:25","source":"热爱编程的通信人","tag":"technique","mediaSite":null,"pathname":"/article/7112632278815359502/","loginUserInfo":null,"favorite":false,"relation":{"isFollowing":false,"isFollowed":false},"likeData":{"userLikeStatus":0,"count":0},"isSelf":false,"content":"

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

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

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


[root@k8s-master01 ~]# docker versionnClient: Docker Engine - Communityn Version: 20.10.17n API version: 1.40n Go version: go1.17.11n Git commit: 100c701n Built: Mon Jun 6 23:05:12 2022n OS/Arch: linux/amd64n Context: defaultn Experimental: truennServer: Docker Engine - Communityn Engine:n Version: 19.03.15n API version: 1.40 (minimum version 1.12)n Go version: go1.13.15n Git commit: 99e3ed8919n Built: Sat Jan 30 03:16:33 2021n OS/Arch: linux/amd64n Experimental: falsen containerd:n Version: 1.6.6n GitCommit: 10c12954828e7c7c9b6e0ea9b0c02b01407d3ae1n runc:n Version: 1.1.2n GitCommit: v1.1.2-0-ga916309n docker-init:n Version: 0.18.0n GitCommit: fec3683n[root@k8s-master01 ~]# n

[root@k8s-master01 ~]# docker infonClient:n Context: defaultn Debug Mode: falsen Plugins:n app: Docker App (Docker Inc., v0.9.1-beta3)n buildx: Docker Buildx (Docker Inc., v0.8.2-docker)nWARNING: 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 errornnServer:n Containers: 10n Running: 4n Paused: 0n Stopped: 6n Images: 5n Server Version: 19.03.15n Storage Driver: devicemapper # aufs、overlay brtfsn Pool Name: docker-253:0-3035967-pooln Pool Blocksize: 65.54kBn Base Device Size: 10.74GBn Backing Filesystem: xfsn Udev Sync Supported: truen Data file: /dev/loop0n Metadata file: /dev/loop1n Data loop file: /var/lib/docker/devicemapper/devicemapper/datan Metadata loop file: /var/lib/docker/devicemapper/devicemapper/metadatan Data Space Used: 619.4MBn Data Space Total: 107.4GBn Data Space Available: 10.63GBn Metadata Space Used: 18.56MBn Metadata Space Total: 2.147GBn Metadata Space Available: 2.129GBn Thin Pool Minimum Free Space: 10.74GBn Deferred Removal Enabled: truen Deferred Deletion Enabled: truen Deferred Deleted Device Count: 0n Library Version: 1.02.170-RHEL7 (2020-03-24)n Logging Driver: json-file # json-file存在本地n Cgroup Driver: systemdn Plugins:n Volume: localn Network: bridge host ipvlan macvlan null overlayn Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslogn Swarm: inactiven Runtimes: runcn Default Runtime: runcn Init Binary: docker-initn containerd version: 10c12954828e7c7c9b6e0ea9b0c02b01407d3ae1n runc version: v1.1.2-0-ga916309n init version: fec3683n Security Options:n seccompn Profile: defaultn Kernel Version: 4.19.12-1.el7.elrepo.x86_64n Operating System: CentOS Linux 7 (Core)n OSType: linuxn Architecture: x86_64n CPUs: 2n Total Memory: 1.923GiBn Name: k8s-master01n ID: PPTJ:RXWD:5IWS:62IC:2GP4:RKI7:R233:3RGW:D6LN:4IXW:WUUZ:NJHRn Docker Root Dir: /var/lib/docker # 可以更改的,ssd的硬盘,最好使用一个单独的磁盘进行挂载n Debug Mode: falsen Registry: https://index.docker.io/v1/ # hub.docker.comn Labels:n Experimental: falsen Insecure Registries:n 127.0.0.0/8n Live Restore Enabled: falsennWARNING: the devicemapper storage-driver is deprecated, and will be removed in a future release.nWARNING: devicemapper: usage of loopback devices is strongly discouraged for production use.n Use `--storage-opt dm.thinpooldev` to specify a custom block storage device.n[root@k8s-master01 ~]#

[root@k8s-master01 ~]# docker search centosnNAME DESCRIPTION STARS OFFICIAL AUTOMATEDncentos The official build of CentOS. 7199 [OK] ncentos/systemd systemd enabled base container. 108 [OK]ncentos/mysql-57-centos7 MySQL 5.7 SQL database server 95 nkasmweb/centos-7-desktop CentOS 7 desktop for Kasm Workspaces 21 ncentos/mongodb-36-centos7 MongoDB NoSQL database server 8 nkasmweb/core-centos-7 CentOS 7 base image for Kasm Workspaces 3 ncontinuumio/centos5_gcc5_base 3 ncouchbase/centos7-systemd centos7-systemd images with additional debug… 1 [OK]nspack/centos7 CentOS 7 with Spack preinstalled 1 nspack/centos-stream 0 ncouchbase/centos-72-jenkins-core 0 nfnndsc/centos-python3 Source for a slim Centos-based Python3 image… 0 [OK]ncouchbase/centos-72-java-sdk 0 ncouchbase/centos-69-sdk-build 0 ncouchbase/centos-70-sdk-build 0 ndatadog/centos-i386 0 nspack/centos6 CentOS 6 with Spack preinstalled 0 nstarlingx/stx-centos StarlingX centos 0 nibmcom/fhe-toolkit-centos-amd64 The IBM Fully Homomorphic Encryption (FHE) T… 0 nibmcom/fhe-toolkit-centos The IBM Fully Homomorphic Encryption (FHE) T… 0 napache/couchdbci-centos Apache CouchDB CI CentOS 0 nsilintl/openldap OpenLDAP base image on Centos 6 0 [OK]nbitnami/centos-extras-base 0 nbitnami/centos-base-buildpack Centos base compilation image 0 [OK]ncouchbase/centos-69-sdk-nodevtoolset-build 0 n[root@k8s-master01 ~]# docker search nginxnNAME DESCRIPTION STARS OFFICIAL AUTOMATEDnnginx Official build of Nginx. 16983 [OK] nlinuxserver/nginx An Nginx container, brought to you by LinuxS… 169 nbitnami/nginx Bitnami nginx Docker Image 131 [OK]nubuntu/nginx Nginx, a high-performance reverse proxy & we… 52 nbitnami/nginx-ingress-controller Bitnami Docker Image for NGINX Ingress Contr… 18 [OK]nrancher/nginx-ingress-controller 10 nclearlinux/nginx Nginx reverse proxy server with the benefits… 4 nibmcom/nginx-ingress-controller Docker Image for IBM Cloud Private-CE (Commu… 4 nbitnami/nginx-ldap-auth-daemon 3 nrancher/nginx 2 nbitnami/nginx-exporter 2 nvmware/nginx 2 nrancher/nginx-ingress-controller-defaultbackend 2 ncircleci/nginx This image is for internal use 2 nvmware/nginx-photon 1 nrapidfort/nginx RapidFort optimized, hardened image for NGINX 1 nwallarm/nginx-ingress-controller Kubernetes Ingress Controller with Wallarm e… 1 nbitnami/nginx-intel 1 nkasmweb/nginx An Nginx image based off nginx:alpine and in… 1 nrancher/nginx-conf 0 nibmcom/nginx-ingress-controller-ppc64le Docker Image for IBM Cloud Private-CE (Commu… 0 ncontinuumio/nginx-ingress-ws 0 nrancher/nginx-ingress-controller-amd64 0 nibmcom/nginx-ppc64le Docker image for nginx-ppc64le 0 nrancher/nginx-ssl 0 n[root@k8s-master01 ~]#

[root@k8s-master01 ~]# docker pull alpine:latest # 本地若有镜像不会重复拉取nlatest: Pulling from library/alpinen2408cc74d12b: Pull complete nDigest: sha256:686d8c9dfa6f3ccfc8230bc3178d23f84eeaf7e457f36f271ab1acc53015037cnStatus: Downloaded newer image for alpine:latestndocker.io/library/alpine:latestnYou have new mail in /var/spool/mail/rootn[root@k8s-master01 ~]#

[root@k8s-master01 ~]# docker tag alpine:latest guolianggsta/alpine:latest

[root@k8s-master01 ~]# docker tag alpine:latest guolianggsta/alpine:latestnjConfigure a credential helper to remove this warning. Seenhttps://docs.docker.com/engine/reference/commandline/login/#credentials-storennLogin Succeededn[root@k8s-master01 ~]# n[root@k8s-master01 ~]# docker push guolianggsta/alpine:latestnThe push refers to repository [docker.io/guolianggsta/alpine]n24302eb7d908: Mounted from library/alpine nlatest: digest: sha256:4ff3ca91275773af45cb4b0834e12b7eb47d1c18f770a0b151381cd227f4c253 size: 528n[root@k8s-master01 ~]#

[root@k8s-master01 ~]# docker run -it alpine:latest shn/ # n/ # n/ # n/ # nn[root@k8s-master01 ~]# docker run -it nginx:1.14.2 shnUnable to find image 'nginx:1.14.2' locallyn1.14.2: Pulling from library/nginxn27833a3ba0a5: Pull complete n0f23e58bd0b7: Pull complete n8ca774778e85: Pull complete nDigest: sha256:f7988fb6c02e0ce69257d9bd9cf37ae20a60f1df7563c3a2a6abe24160306b8dnStatus: Downloaded newer image for nginx:1.14.2n# n# nn[root@k8s-master01 ~]# docker run -d nginx:1.14.2 sh # -d表示后台启动一个进程nf3925ab212784ce86d350776d3b0daca2688f0a0edf28ff621d1cfe7528e04b9n[root@k8s-master01 ~]#

[root@k8s-master01 ~]# docker logs -f b1aa9b735420n{"level":"info","msg":"Kubernetes host: https://10.96.0.1:443","time":"2022-06-23T02:13:21Z"}n192.168.1.107 - - [23/Jun/2022:02:13:52 +0000] "GET / HTTP/1.1" 200 6 "" "kube-probe/1.20"n192.168.1.107 - - [23/Jun/2022:02:14:02 +0000] "GET / HTTP/1.1" 200 6 "" "kube-probe/1.20"n192.168.1.107 - - [23/Jun/2022:02:14:12 +0000] "GET / HTTP/1.1" 200 6 "" "kube-probe/1.20"n{"level":"info","msg":"Database updated: 5 nodes, 10 pods","time":"2022-06-23T02:14:21Z"}n192.168.1.107 - - [23/Jun/2022:02:14:22 +0000] "GET / HTTP/1.1" 200 6 "" "kube-probe/1.20"n172.25.92.64 - - [23/Jun/2022:02:14:24 +0000] "GET /healthz HTTP/1.1" 200 13 "" "dashboard/v2.0.4"n192.168.1.107 - - [23/Jun/2022:02:14:32 +0000] "GET / HTTP/1.1" 200 6 "" "kube-probe/1.20"n192.168.1.107 - - [23/Jun/2022:02:14:42 +0000] "GET / HTTP/1.1" 200 6 "" "kube-probe/1.20"n192.168.1.107 - - [23/Jun/2022:02:14:52 +0000] "GET / HTTP/1.1" 200 6 "" "kube-probe/1.20"n172.25.92.64 - - [23/Jun/2022:02:14:54 +0000] "GET /healthz HTTP/1.1" 200 13 "" "dashboard/v2.0.4"n192.168.1.107 - - [23/Jun/2022:02:15:02 +0000] "GET / HTTP/1.1" 200 6 "" "kube-probe/1.20"n192.168.1.107 - - [23/Jun/2022:02:15:12 +0000] "GET / HTTP/1.1" 200 6 "" "kube-probe/1.20"n{"level":"info","msg":"Database updated: 5 nodes, 10 pods","time":"2022-06-23T02:15:21Z"}n192.168.1.107 - - [23/Jun/2022:02:15:22 +0000] "GET / HTTP/1.1" 200 6 "" "kube-probe/1.20"n172.25.92.64 - - [23/Jun/2022:02:15:24 +0000] "GET /healthz HTTP/1.1" 200 13 "" "dashboard/v2.0.4"n192.168.1.107 - - [23/Jun/2022:02:15:32 +0000] "GET / HTTP/1.1" 200 6 "" "kube-probe/1.20"n192.168.1.107 - - [23/Jun/2022:02:15:42 +0000] "GET / HTTP/1.1" 200 6 "" "kube-probe/1.20"

[root@k8s-master01 ~]# docker psnCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMESnb1aa9b735420 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_1n646932befa6a 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_2n27a98fe675fc d45bf977dfbf "start_runit" 24 hours ago Up 24 hours k8s_calico-node_calico-node-tstnv_kube-system_9f4ae917-7448-4a99-aca2-f7126c768a0a_1n2bcad372e77e 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_1n[root@k8s-master01 ~]# n[root@k8s-master01 ~]# n[root@k8s-master01 ~]# docker ps -anCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMESnf3925ab21278 nginx:1.14.2 "sh" 20 minutes ago Exited (0) 20 minutes ago optimistic_joliotndc89f8fb24c8 nginx:1.14.2 "sh" 22 minutes ago Exited (0) 20 minutes ago sleepy_borgn04cd7a480254 alpine:latest "sh" 24 minutes ago Exited (0) 23 minutes ago adoring_faradaynd99c0a30c82c alpine:latest "bash" 24 minutes ago Created distracted_khorananb1aa9b735420 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_1n646932befa6a 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_2n27a98fe675fc d45bf977dfbf "start_runit" 24 hours ago Up 24 hours k8s_calico-node_calico-node-tstnv_kube-system_9f4ae917-7448-4a99-aca2-f7126c768a0a_1nec82192edef4 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_0nab63d540576f 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_1n2bcad372e77e 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_1n6b91d896f94c 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_0nf15b45ac36ef 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_0ne56fca8267fa 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_0ndc9471add10b 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_0n[root@k8s-master01 ~]# n[root@k8s-master01 ~]# n[root@k8s-master01 ~]# docker ps -qnb1aa9b735420n646932befa6an27a98fe675fcn2bcad372e77en[root@k8s-master01 ~]# n[root@k8s-master01 ~]# n[root@k8s-master01 ~]# docker ps -qanf3925ab21278ndc89f8fb24c8n04cd7a480254nd99c0a30c82cnb1aa9b735420n646932befa6an27a98fe675fcnec82192edef4nab63d540576fn2bcad372e77en6b91d896f94cnf15b45ac36efne56fca8267fandc9471add10bn[root@k8s-master01 ~]#

[root@k8s-master01 ~]# docker exec -it 27a98fe675fc bashn[root@k8s-master01 /]# n[root@k8s-master01 /]# n[root@k8s-master01 /]# lsn@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 varn[root@k8s-master01 /]#

[root@k8s-master01 ~]# echo "test cp" > index.htmln[root@k8s-master01 ~]# n[root@k8s-master01 ~]# lsnanaconda-ks.cfg index.html k8s-ha-install kernel-ml-devel-4.19.12-1.el7.elrepo.x86_64.rpmnetcd-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.gzn[root@k8s-master01 ~]# docker cp index.html 6f7256e24436:/usr/share/nginx/html/n[root@k8s-master01 ~]# n[root@k8s-master01 ~]# docker cp 6f7256e24436:/usr/share/nginx/html/index.html .n[root@k8s-master01 ~]#

[root@k8s-master01 ~]# docker ps -anCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMESn6f7256e24436 nginx:1.14.2 "nginx -g 'daemon of…" 4 minutes ago Up 4 minutes 0.0.0.0:12345->80/tcp keen_mccarthynf3925ab21278 nginx:1.14.2 "sh" 35 minutes ago Exited (0) 35 minutes ago optimistic_joliotndc89f8fb24c8 nginx:1.14.2 "sh" 38 minutes ago Exited (0) 36 minutes ago sleepy_borgn04cd7a480254 alpine:latest "sh" 39 minutes ago Exited (0) 39 minutes ago adoring_faradaynd99c0a30c82c alpine:latest "bash" 40 minutes ago Created distracted_khorananb1aa9b735420 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_1n646932befa6a 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_2n27a98fe675fc d45bf977dfbf "start_runit" 24 hours ago Up 24 hours k8s_calico-node_calico-node-tstnv_kube-system_9f4ae917-7448-4a99-aca2-f7126c768a0a_1nec82192edef4 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_0nab63d540576f 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_1n2bcad372e77e 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_1n6b91d896f94c 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_0nf15b45ac36ef 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_0ne56fca8267fa 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_0ndc9471add10b 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_0n[root@k8s-master01 ~]# n[root@k8s-master01 ~]# docker rm f3925ab21278nf3925ab21278n[root@k8s-master01 ~]# docker imagesnREPOSITORY TAG IMAGE ID CREATED SIZEnguolianggsta/alpine latest e66264b98777 4 weeks ago 5.52MBnalpine latest e66264b98777 4 weeks ago 5.52MBnregistry.cn-beijing.aliyuncs.com/dotbalo/node v3.15.3 d45bf977dfbf 21 months ago 262MBnregistry.cn-beijing.aliyuncs.com/dotbalo/pod2daemon-flexvol v3.15.3 963564fb95ed 21 months ago 22.8MBnregistry.cn-beijing.aliyuncs.com/dotbalo/cni v3.15.3 ca5564c06ea0 21 months ago 110MBnregistry.cn-beijing.aliyuncs.com/dotbalo/metrics-scraper v1.0.4 86262685d9ab 2 years ago 36.9MBnregistry.cn-hangzhou.aliyuncs.com/google_containers/pause-amd64 3.2 80d28bedfe5d 2 years ago 683kBnnginx 1.14.2 295c7be07902 3 years ago 109MBn[root@k8s-master01 ~]# docker rmi guolianggsta/alpinenUntagged: guolianggsta/alpine:latestnUntagged: guolianggsta/alpine@sha256:4ff3ca91275773af45cb4b0834e12b7eb47d1c18f770a0b151381cd227f4c253n[root@k8s-master01 ~]#

[root@k8s-master01 ~]# docker psnCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMESn6f7256e24436 nginx:1.14.2 "nginx -g 'daemon of…" 6 minutes ago Up 6 minutes 0.0.0.0:12345->80/tcp keen_mccarthynb1aa9b735420 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_1n646932befa6a 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_2n27a98fe675fc d45bf977dfbf "start_runit" 24 hours ago Up 24 hours k8s_calico-node_calico-node-tstnv_kube-system_9f4ae917-7448-4a99-aca2-f7126c768a0a_1n2bcad372e77e 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_1n[root@k8s-master01 ~]# n[root@k8s-master01 ~]# docker stop 6f7256e24436n6f7256e24436n[root@k8s-master01 ~]# docker psnCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMESnb1aa9b735420 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_1n646932befa6a 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_2n27a98fe675fc d45bf977dfbf "start_runit" 24 hours ago Up 24 hours k8s_calico-node_calico-node-tstnv_kube-system_9f4ae917-7448-4a99-aca2-f7126c768a0a_1n2bcad372e77e 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_1n[root@k8s-master01 ~]# n[root@k8s-master01 ~]# docker start 6f7256e24436n6f7256e24436n[root@k8s-master01 ~]# docker ps nCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMESn6f7256e24436 nginx:1.14.2 "nginx -g 'daemon of…" 7 minutes ago Up 7 seconds 0.0.0.0:12345->80/tcp keen_mccarthynb1aa9b735420 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_1n646932befa6a 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_2n27a98fe675fc d45bf977dfbf "start_runit" 24 hours ago Up 24 hours k8s_calico-node_calico-node-tstnv_kube-system_9f4ae917-7448-4a99-aca2-f7126c768a0a_1n2bcad372e77e 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_1n[root@k8s-master01 ~]#

[root@k8s-master01 ~]# docker history alpinenIMAGE CREATED CREATED BY SIZE COMMENTne66264b98777 4 weeks ago /bin/sh -c #(nop) CMD ["/bin/sh"] 0B n<missing> 4 weeks ago /bin/sh -c #(nop) ADD file:8e81116368669ed3d… 5.52MB n[root@k8s-master01 ~]#

[root@k8s-master01 ~]# docker psnCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMESn6f7256e24436 nginx:1.14.2 "nginx -g 'daemon of…" 9 minutes ago Up 2 minutes 0.0.0.0:12345->80/tcp keen_mccarthynb1aa9b735420 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_1n646932befa6a 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_2n27a98fe675fc d45bf977dfbf "start_runit" 24 hours ago Up 24 hours k8s_calico-node_calico-node-tstnv_kube-system_9f4ae917-7448-4a99-aca2-f7126c768a0a_1n2bcad372e77e 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_1n[root@k8s-master01 ~]# n[root@k8s-master01 ~]# n[root@k8s-master01 ~]# docker cp index.html 6f7256e24436:/usr/share/nginx/html/n[root@k8s-master01 ~]# n[root@k8s-master01 ~]# docker commit -a "guolianggsta" -m "add index.html" 6f7256e24436 nginx:commitnsha256:029ceeabb47df6459ce0745b691a2ef1477e3627ff3371ccffd481534ebe6c47n[root@k8s-master01 ~]# n[root@k8s-master01 ~]# n[root@k8s-master01 ~]# docker run -it --rm nginx:commit bashnroot@bab55273616f:/# cd /usr/share/nginx/html/nroot@bab55273616f:/usr/share/nginx/html# lsn50x.html index.htmlnroot@bab55273616f:/usr/share/nginx/html# ls -lntotal 8n-rw-r--r-- 1 root root 537 Dec 4 2018 50x.htmln-rw-r--r-- 1 root root 8 Jun 24 02:32 index.htmlnroot@bab55273616f:/usr/share/nginx/html#

docker build在之后的课程讲解

","imageList":[],"mediaInfo":{"userId":"MS4wLjABAAAAkpPCAz9cLGlKS4Lt5YRy_lcpbGx_vz2orES4PG21wJ8","unsafeUserId":"3647110326","name":"热爱编程的通信人","avatarUrl":"https://p6.toutiaoimg.com/origin/user-avatar/388b6e743b8f2969a150933ef38fa159","description":"白天办公室打杂,晚上实验室码字","userVerified":1,"userAuthInfo":{"auth_type":"0","auth_info":"中国电信股份有限公司研究院通信技术高级工程师"}},"seoTDK":{"title":"(2022版)一套教程搞定k8s安装到实战 - Docker基本命令-今日头条","description":"一边学习一边整理老师的课程内容及试验笔记,并与大家分享,侵权即删,谢谢支持!docker build在之后的课程讲解。","keywords":"Docker,Git,操作系统,Linux,Bilibili,CSDN","publishTimestamp":"1656041106","modifiedTimestamp":"1656042917"},"logId":"20220624122338010150140037108E52AE","sylpageConfig":{"card":{"id":""}},"identity":{"web_id":"7111199547455817229","user_is_login":false},"abtestInfo":{"rsp_type":5,"version_name":"4252807,4164637","parameters":{"feat_repost_type":{"new":true},"home_nav_conf":{"dcd_out":1},"local_filter":{"core_filter":{"filter_list":{"ms::TicaiFilter":true}}},"page_upgrade":{"new_profile":true,"video_double_column":true},"sati":{"enable_ad_prime":true,"enable_sorter_optimus":true,"prime_rule_rank_version":"toutiao_web","use_toutiao_web_feed":true,"format_max_consecutive_middle":2,"format_max_consecutive_nogroups":3,"enable_reduce_nogroup":true},"seraph":{"score_rule":{"default":{"replace":{"group_util":"_CTR - 1000*dislike"}},"new_user":{"replace":{"group_util":"_CTR - 1000*dislike"}}}},"sort":{"allowed_ticai":["forum_post","pgc_text","pgc_video"]},"video_detail_page_upgrade":{"new_page":true}},"env_flag":0},"localCityInfo":{"name":"北京","code":"110000","channelId":3202164529},"showResearch":false}}

返回顶部