- 尚硅谷大数据技术-教程-学习路线-笔记汇总表【课程资料下载】
- 视频地址:尚硅谷Docker实战教程(docker教程天花板)_哔哩哔哩_bilibili
- 尚硅谷Docker实战教程-笔记01【理念简介、官网介绍、平台入门图解、平台架构图解】
- 尚硅谷Docker实战教程-笔记02【安装docker、镜像加速器配置】
- 尚硅谷Docker实战教程-笔记03【Docker常用命令】
- 尚硅谷Docker实战教程-笔记04【Docker镜像】
- 尚硅谷Docker实战教程-笔记05【】
目录
1.基础篇
3.Docker常用命令
P015【15_帮助启动类命令】07:32
P016【16_镜像命令】22:56
P017【17_ubuntu容器说明】03:11
P018【18_容器命令A】16:30
P019【19_容器命令B】04:24
P020【20_容器命令C】10:36
P021【21_容器命令D】25:01
P022【22_容器命令E】09:15
1.基础篇
3.Docker常用命令
P015【15_帮助启动类命令】07:32
[root@node001 docker]# docker status docker
docker: 'status' is not a docker command.
See 'docker --help'
[root@node001 docker]# systemctl status docker
● docker.service - Docker Application Container EngineLoaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)Active: active (running) since 五 2023-05-26 15:14:55 CST; 17min agoDocs: https://docs.docker.comMain PID: 4160 (dockerd)Tasks: 11Memory: 30.2MCGroup: /system.slice/docker.service└─4160 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock5月 26 15:14:54 node001 dockerd[4160]: time="2023-05-26T15:14:54.528872384+08:00" level=info msg="Starting up"
5月 26 15:14:54 node001 dockerd[4160]: time="2023-05-26T15:14:54.612128512+08:00" level=info msg="[graphdriver] using prior storage driver: overlay2"
5月 26 15:14:54 node001 dockerd[4160]: time="2023-05-26T15:14:54.613619570+08:00" level=info msg="Loading containers: start."
5月 26 15:14:55 node001 dockerd[4160]: time="2023-05-26T15:14:55.000236197+08:00" level=info msg="Default bridge (docker0) is assigned with an IP ... address"
5月 26 15:14:55 node001 dockerd[4160]: time="2023-05-26T15:14:55.128860025+08:00" level=info msg="Loading containers: done."
5月 26 15:14:55 node001 dockerd[4160]: time="2023-05-26T15:14:55.180968994+08:00" level=info msg="Docker daemon" commit=463850e graphdriver=overla...on=24.0.1
5月 26 15:14:55 node001 dockerd[4160]: time="2023-05-26T15:14:55.181125988+08:00" level=info msg="Daemon has completed initialization"
5月 26 15:14:55 node001 dockerd[4160]: time="2023-05-26T15:14:55.270751801+08:00" level=info msg="API listen on /run/docker.sock"
5月 26 15:14:55 node001 systemd[1]: Started Docker Application Container Engine.
5月 26 15:15:19 node001 dockerd[4160]: time="2023-05-26T15:15:19.315721290+08:00" level=info msg="ignoring event" container=3ff6498fa0a7d34b5995ac...skDelete"
Hint: Some lines were ellipsized, use -l to show in full.
[root@node001 docker]# docker --helpUsage: docker [OPTIONS] COMMANDA self-sufficient runtime for containersCommon Commands:run Create and run a new container from an imageexec Execute a command in a running containerps List containersbuild Build an image from a Dockerfilepull Download an image from a registrypush Upload an image to a registryimages List imageslogin Log in to a registrylogout Log out from a registrysearch Search Docker Hub for imagesversion Show the Docker version informationinfo Display system-wide informationManagement Commands:builder Manage buildsbuildx* Docker Buildx (Docker Inc., v0.10.4)compose* Docker Compose (Docker Inc., v2.18.1)container Manage containerscontext Manage contextsimage Manage imagesmanifest Manage Docker image manifests and manifest listsnetwork Manage networksplugin Manage pluginssystem Manage Dockertrust Manage trust on Docker imagesvolume Manage volumesSwarm Commands:swarm Manage SwarmCommands:attach Attach local standard input, output, and error streams to a running containercommit Create a new image from a container's changescp Copy files/folders between a container and the local filesystemcreate Create a new containerdiff Inspect changes to files or directories on a container's filesystemevents Get real time events from the serverexport Export a container's filesystem as a tar archivehistory Show the history of an imageimport Import the contents from a tarball to create a filesystem imageinspect Return low-level information on Docker objectskill Kill one or more running containersload Load an image from a tar archive or STDINlogs Fetch the logs of a containerpause Pause all processes within one or more containersport List port mappings or a specific mapping for the containerrename Rename a containerrestart Restart one or more containersrm Remove one or more containersrmi Remove one or more imagessave Save one or more images to a tar archive (streamed to STDOUT by default)start Start one or more stopped containersstats Display a live stream of container(s) resource usage statisticsstop Stop one or more running containerstag Create a tag TARGET_IMAGE that refers to SOURCE_IMAGEtop Display the running processes of a containerunpause Unpause all processes within one or more containersupdate Update configuration of one or more containerswait Block until one or more containers stop, then print their exit codesGlobal 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 "dockercontext use")-D, --debug Enable debug mode-H, --host list Daemon socket 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 quitRun 'docker COMMAND --help' for more information on a command.For more help on how to use Docker, head to https://docs.docker.com/go/guides/
[root@node001 docker]# docker cp --helpUsage: docker cp [OPTIONS] CONTAINER:SRC_PATH DEST_PATH|-docker cp [OPTIONS] SRC_PATH|- CONTAINER:DEST_PATHCopy files/folders between a container and the local filesystemUse '-' as the source to read a tar archive from stdin
and extract it to a directory destination in a container.
Use '-' as the destination to stream a tar archive of a
container source to stdout.Aliases:docker container cp, docker cpOptions:-a, --archive Archive mode (copy all uid/gid information)-L, --follow-link Always follow symbol link in SRC_PATH-q, --quiet Suppress progress output during copy. Progress output is automatically suppressed if no terminal is attached
[root@node001 docker]#
[root@node001 atguigu]# man docker-run
[root@node001 atguigu]#
P016【16_镜像命令】22:56
[root@node001 atguigu]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest 9c7a54a9a43c 7 weeks ago 13.3kB
[root@node001 atguigu]# docker image isUsage: docker image COMMANDManage imagesCommands:build Build an image from a Dockerfilehistory Show the history of an imageimport Import the contents from a tarball to create a filesystem imageinspect Display detailed information on one or more imagesload Load an image from a tar archive or STDINls List imagesprune Remove unused imagespull Download an image from a registrypush Upload an image to a registryrm Remove one or more imagessave Save one or more images to a tar archive (streamed to STDOUT by default)tag Create a tag TARGET_IMAGE that refers to SOURCE_IMAGERun 'docker image COMMAND --help' for more information on a command.
[root@node001 atguigu]# docker search hello-world
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
hello-world Hello World! (an example of minimal Dockeriz… 2051 [OK]
rancher/hello-world 4
okteto/hello-world 0
golift/hello-world Hello World Go-App built by Go Lift Applicat… 0
tacc/hello-world 0
armswdev/c-hello-world Simple hello-world C program on Alpine Linux… 0
tutum/hello-world Image to test docker deployments. Has Apache… 90 [OK]
thomaspoignant/hello-world-rest-json This project is a REST hello-world API to bu… 2
kitematic/hello-world-nginx A light-weight nginx container that demonstr… 152
dockercloud/hello-world Hello World! 20 [OK]
ansibleplaybookbundle/hello-world-apb An APB which deploys a sample Hello World! a… 1 [OK]
ansibleplaybookbundle/hello-world-db-apb An APB which deploys a sample Hello World! a… 2 [OK]
crccheck/hello-world Hello World web server in under 2.5 MB 17 [OK]
strimzi/hello-world-consumer 0
strimzi/hello-world-producer 0
businessgeeks00/hello-world-nodejs 0
koudaiii/hello-world 0
freddiedevops/hello-world-spring-boot 0
strimzi/hello-world-streams 0
garystafford/hello-world Simple hello-world Spring Boot service for t… 0 [OK]
ppc64le/hello-world Hello World! (an example of minimal Dockeriz… 2
tsepotesting123/hello-world 0
kevindockercompany/hello-world 0
dandando/hello-world-dotnet 0
vad1mo/hello-world-rest A simple REST Service that echoes back all t… 7 [OK]
[root@node001 atguigu]# docker search mysql
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
mysql MySQL is a widely used, open-source relation… 14263 [OK]
mariadb MariaDB Server is a high performing open sou… 5453 [OK]
percona Percona Server is a fork of the MySQL relati… 616 [OK]
phpmyadmin phpMyAdmin - A web interface for MySQL and M… 829 [OK]
bitnami/mysql Bitnami MySQL Docker Image 90 [OK]
circleci/mysql MySQL is a widely used, open-source relation… 29
bitnami/mysqld-exporter 5
ubuntu/mysql MySQL open source fast, stable, multi-thread… 51
cimg/mysql 0
rapidfort/mysql RapidFort optimized, hardened image for MySQL 23
rapidfort/mysql8-ib RapidFort optimized, hardened image for MySQ… 9
google/mysql MySQL server for Google Compute Engine 23 [OK]
hashicorp/mysql-portworx-demo 0
rapidfort/mysql-official RapidFort optimized, hardened image for MySQ… 7
newrelic/mysql-plugin New Relic Plugin for monitoring MySQL databa… 1 [OK]
databack/mysql-backup Back up mysql databases to... anywhere! 86
bitnamicharts/mysql 0
linuxserver/mysql A Mysql container, brought to you by LinuxSe… 38
mirantis/mysql 0
docksal/mysql MySQL service images for Docksal - https://d… 0
linuxserver/mysql-workbench 50
vitess/mysqlctld vitess/mysqlctld 1 [OK]
eclipse/mysql Mysql 5.7, curl, rsync 0 [OK]
drupalci/mysql-5.5 https://www.drupal.org/project/drupalci 3 [OK]
drupalci/mysql-5.7 https://www.drupal.org/project/drupalci 0
[root@node001 atguigu]# docker search minio
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
bitnami/minio Bitnami MinIO Docker Image 95
bitnami/minio-client Bitnami MinIO Client Docker Image 11
rancher/minio-minio 1
bitnamicharts/minio 0
corpusops/minio https://github.com/corpusops/docker-images/ 0
longhornio/minio 0
drud/minio 0
hephy/minio 0
silintl/minio-default-server 0
corpusops/minio-k8s-operator https://github.com/corpusops/docker-images/ 0
corpusops/minio-mint https://github.com/corpusops/docker-images/ 0
newrelic/synthetics-minion Synthetics Containerized Private Minion 5
corpusops/minio-doctor https://github.com/corpusops/docker-images/ 0
drud/minio-exporter 0
vulhub/minio 0
jumpserver/minio Multi-Cloud Object Storage 0
minio/minio Multi-Cloud Object Storage 723 [OK]
minio/mc Minio Client (mc) provides a modern alternat… 41 [OK]
minio/console A graphical user interface for MinIO server 15
jumpserver/mc Minio Client (mc) provides a modern alternat… 0
minio/k8s-operator Minio Operator for k8s https://kubernetes.io/ 1
minio/operator 3
minio/kes Description Kes is a tool for managing and … 2
minio/direct-csi Container Storage Interface (CSI) driver for… 0
minio/logsearchapi 2
[root@node001 atguigu]# docker search redis
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
redis Redis is an open source key-value store that… 12181 [OK]
redislabs/redisearch Redis With the RedisSearch module pre-loaded… 56
redislabs/redisinsight RedisInsight - The GUI for Redis 88
redislabs/rebloom A probablistic datatypes module for Redis 23 [OK]
redislabs/redis Clustered in-memory database engine compatib… 38
redis/redis-stack-server redis-stack-server installs a Redis server w… 45
redislabs/rejson RedisJSON - Enhanced JSON data type processi… 53
redis/redis-stack redis-stack installs a Redis server with add… 54
redislabs/redisgraph A graph database module for Redis 26 [OK]
redislabs/redismod An automated build of redismod - latest Redi… 41 [OK]
redislabs/redistimeseries A time series database module for Redis 12
redislabs/operator 7
redislabs/operator-internal This repository contains pre-released versio… 1
redislabs/redis-py 5
redislabs/redis-webcli A tiny Flask app to provide access to Redis … 3 [OK]
redislabs/redisgears An automated build of RedisGears 4
redislabs/k8s-controller-internal 0
redislabs/memtier_benchmark Docker image to run memtier_benchmark 0
redislabs/ng-redis-raft Redis with redis raft module 0
redislabs/k8s-controller 2
redislabs/redisai 5
redislabs/olmtest Test artefact for OLM CSV 0
bitnami/redis Bitnami Redis Docker Image 259 [OK]
redislabs/olm-bundle 0
redislabs/redisml A Redis module that implements several machi… 3 [OK]
[root@node001 atguigu]# docker search --limit redis
invalid argument "redis" for "--limit" flag: strconv.ParseInt: parsing "redis": invalid syntax
See 'docker search --help'.
[root@node001 atguigu]# docker search --limit 5 redis
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
redis Redis is an open source key-value store that… 12181 [OK]
redislabs/redisearch Redis With the RedisSearch module pre-loaded… 56
redislabs/redisinsight RedisInsight - The GUI for Redis 88
redislabs/rebloom A probablistic datatypes module for Redis 23 [OK]
redislabs/redis Clustered in-memory database engine compatib… 38
[root@node001 atguigu]# docker pull hello-world
Using default tag: latest
latest: Pulling from library/hello-world
2db29710123e: Pull complete
Digest: sha256:2498fce14358aa50ead0cc6c19990fc6ff866ce72aeb5546e1d59caac3d0d60f
Status: Downloaded newer image for hello-world:latest
docker.io/library/hello-world:latest
[root@node001 atguigu]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world <none> 9c7a54a9a43c 7 weeks ago 13.3kB
hello-world latest feb5d9fea6a5 21 months ago 13.3kB
[root@node001 atguigu]# docker pull ubuntu
Using default tag: latest
latest: Pulling from library/ubuntu
7b1a6ab2e44d: Pull complete
Digest: sha256:626ffe58f6e7566e00254b638eb7e0f3b11d4da9675088f4781a50ae288f3322
Status: Downloaded newer image for ubuntu:latest
docker.io/library/ubuntu:latest
[root@node001 atguigu]# docker pull redis:6.8.0
Error response from daemon: manifest for redis:6.8.0 not found: manifest unknown: manifest unknown
[root@node001 atguigu]# docker pull redis:6.0.8
6.0.8: Pulling from library/redis
bb79b6b2107f: Pull complete
1ed3521a5dcb: Pull complete
5999b99cee8f: Pull complete
3f806f5245c9: Pull complete
f8a4497572b2: Pull complete
eafe3b6b8d06: Pull complete
Digest: sha256:21db12e5ab3cc343e9376d655e8eabbdbe5516801373e95a8a9e66010c5b8819
Status: Downloaded newer image for redis:6.0.8
docker.io/library/redis:6.0.8
[root@node001 atguigu]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world <none> 9c7a54a9a43c 7 weeks ago 13.3kB
ubuntu latest ba6acccedd29 20 months ago 72.8MB
hello-world latest feb5d9fea6a5 21 months ago 13.3kB
redis 6.0.8 16ecd2772934 2 years ago 104MB
[root@node001 atguigu]# docker images -a
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world <none> 9c7a54a9a43c 7 weeks ago 13.3kB
ubuntu latest ba6acccedd29 20 months ago 72.8MB
hello-world latest feb5d9fea6a5 21 months ago 13.3kB
redis 6.0.8 16ecd2772934 2 years ago 104MB
[root@node001 atguigu]# docker images -q
9c7a54a9a43c
ba6acccedd29
feb5d9fea6a5
16ecd2772934
[root@node001 atguigu]# df -h
文件系统 容量 已用 可用 已用% 挂载点
/dev/mapper/centos-root 45G 26G 17G 62% /
devtmpfs 2.0G 0 2.0G 0% /dev
tmpfs 2.0G 0 2.0G 0% /dev/shm
tmpfs 2.0G 13M 2.0G 1% /run
tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup
/dev/sda1 976M 127M 782M 14% /boot
tmpfs 394M 12K 394M 1% /run/user/42
tmpfs 394M 0 394M 0% /run/user/1001
tmpfs 394M 0 394M 0% /run/user/0
[root@node001 atguigu]# docker system df
TYPE TOTAL ACTIVE SIZE RECLAIMABLE
Images 4 1 177MB 177MB (99%)
Containers 2 0 0B 0B
Local Volumes 0 0 0B 0B
Build Cache 0 0 0B 0B
[root@node001 atguigu]# docker rmi 16ecd2772934
Untagged: redis:6.0.8
Untagged: redis@sha256:21db12e5ab3cc343e9376d655e8eabbdbe5516801373e95a8a9e66010c5b8819
Deleted: sha256:16ecd277293476392b71021cdd585c40ad68f4a7488752eede95928735e39df4
Deleted: sha256:3746030fff867eb26a0338ad9d3ab832e6c19c7dc008090bcfa95c7b9f16f505
Deleted: sha256:1274ec54ad17d15ec95d2180cb1f791057e86dfcdfcc18cd58610a920e145945
Deleted: sha256:18d156147e54edec9a927080fdc0a53c4a8814b0c717b36dc62e637363c1a98d
Deleted: sha256:a8f09c4919857128b1466cc26381de0f9d39a94171534f63859a662d50c396ca
Deleted: sha256:2ae5fa95c0fce5ef33fbb87a7e2f49f2a56064566a37a83b97d3f668c10b43d6
Deleted: sha256:d0fe97fa8b8cefdffcef1d62b65aba51a6c87b6679628a2b50fc6a7a579f764c
[root@node001 atguigu]# docker images -a
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world <none> 9c7a54a9a43c 7 weeks ago 13.3kB
ubuntu latest ba6acccedd29 20 months ago 72.8MB
hello-world latest feb5d9fea6a5 21 months ago 13.3kB
[root@node001 atguigu]# docker pull redis:6.0.8
6.0.8: Pulling from library/redis
bb79b6b2107f: Pull complete
1ed3521a5dcb: Pull complete
5999b99cee8f: Pull complete
3f806f5245c9: Pull complete
f8a4497572b2: Pull complete
eafe3b6b8d06: Pull complete
Digest: sha256:21db12e5ab3cc343e9376d655e8eabbdbe5516801373e95a8a9e66010c5b8819
Status: Downloaded newer image for redis:6.0.8
docker.io/library/redis:6.0.8
[root@node001 atguigu]# docker images -qa
9c7a54a9a43c
ba6acccedd29
feb5d9fea6a5
16ecd2772934
[root@node001 atguigu]# history
P017【17_ubuntu容器说明】03:11
[root@node001 atguigu]# docker images -a
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world <none> 9c7a54a9a43c 7 weeks ago 13.3kB
ubuntu latest ba6acccedd29 20 months ago 72.8MB
hello-world latest feb5d9fea6a5 21 months ago 13.3kB
redis 6.0.8 16ecd2772934 2 years ago 104MB
[root@node001 atguigu]#
P018【18_容器命令A】16:30
i interactive
t tyy
shell交互命令的接口
[root@node001 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world <none> 9c7a54a9a43c 7 weeks ago 13.3kB
ubuntu latest ba6acccedd29 20 months ago 72.8MB
hello-world latest feb5d9fea6a5 21 months ago 13.3kB
redis 6.0.8 16ecd2772934 2 years ago 104MB
[root@node001 ~]# docker run hello-worldHello 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 theexecutable that produces the output you are currently reading.4. The Docker daemon streamed that output to the Docker client, which sent itto your terminal.To try something more ambitious, you can run an Ubuntu container with:$ docker run -it ubuntu bashShare 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/[root@node001 ~]# docker run ubuntu
[root@node001 ~]# docker run -it ubuntu /bin/bash
root@a37594fd6c7e:/# ps -ef
UID PID PPID C STIME TTY TIME CMD
root 1 0 1 11:40 pts/0 00:00:00 /bin/bash
root 9 1 0 11:40 pts/0 00:00:00 ps -ef
root@a37594fd6c7e:/# ls
bin boot dev etc home lib lib32 lib64 libx32 media mnt opt proc root run sbin srv sys tmp usr var
root@a37594fd6c7e:/# exit
exit
[root@node001 ~]# docker run -it ubuntu /bin/bash
root@8342de29884a:/#
[root@node001 ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a37594fd6c7e ubuntu "/bin/bash" 2 minutes ago Up 2 minutes zealous_swirles
[root@node001 ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@node001 ~]# docker run -it --name=myu1 ubuntu bash
root@6c0111214702:/#
[root@node001 ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6c0111214702 ubuntu "bash" 9 seconds ago Up 8 seconds myu1
8342de29884a ubuntu "/bin/bash" 36 seconds ago Up 35 seconds determined_keldysh
[root@node001 ~]#
P019【19_容器命令B】04:24
OPTIONS说明(常用):
- -a:列出当前所有正在运行的容器+历史上运行过的。
- -l:显示最近创建的容器。
- -n:显示最近n个创建的容器。
- -q:静默模式,只显示容器编号。
[root@node001 ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@node001 ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6c0111214702 ubuntu "bash" 15 minutes ago Exited (129) 7 minutes ago myu1
8342de29884a ubuntu "/bin/bash" 15 minutes ago Exited (0) 7 minutes ago determined_keldysh
a37594fd6c7e ubuntu "/bin/bash" 24 minutes ago Exited (0) 16 minutes ago zealous_swirles
cccf6112cf2f ubuntu "bash" 24 minutes ago Exited (0) 24 minutes ago eager_grothendieck
b09066c13913 hello-world "/hello" 40 minutes ago Exited (0) 40 minutes ago unruffled_sinoussi
3ff6498fa0a7 9c7a54a9a43c "/hello" 4 weeks ago Exited (0) 4 weeks ago vigorous_mcnulty
7b023b885d8c 9c7a54a9a43c "/hello" 4 weeks ago Exited (0) 4 weeks ago gallant_lehmann
[root@node001 ~]# docker ps -l
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6c0111214702 ubuntu "bash" 15 minutes ago Exited (129) 8 minutes ago myu1
[root@node001 ~]#
P020【20_容器命令C】10:36
P021【21_容器命令D】25:01
[root@node001 ~]# docker top angry_lewin
UID PID PPID C STIME TTY TIME CMD
polkitd 76461 76441 0 20:55 ? 00:00:01 redis-server *:6379
[root@node001 ~]# docker exec -it angry_lewin /bin/bash
root@3fdf86ecd5d1:/data# redis-cli -p 6379
127.0.0.1:6379> ping
PONG
127.0.0.1:6379> set k1 v1
OK
127.0.0.1:6379> get k1
"v1"
127.0.0.1:6379>
P022【22_容器命令E】09:15
[root@node001 ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3fdf86ecd5d1 redis:6.0.8 "docker-entrypoint.s…" 51 minutes ago Up 51 minutes 6379/tcp angry_lewin
[root@node001 ~]# docker run -it ubuntu /bin/bash
root@438af94a059d:/# [root@node001 ~]#
[root@node001 ~]#
[root@node001 ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
438af94a059d ubuntu "/bin/bash" 7 seconds ago Up 6 seconds reverent_poitras
3fdf86ecd5d1 redis:6.0.8 "docker-entrypoint.s…" 52 minutes ago Up 52 minutes 6379/tcp angry_lewin
[root@node001 ~]# docker exec -it reverent_poitras /bin/bash
root@438af94a059d:/# pwd
/
root@438af94a059d:/# ll
total 56
drwxr-xr-x 1 root root 4096 Jun 29 13:46 ./
drwxr-xr-x 1 root root 4096 Jun 29 13:46 ../
-rwxr-xr-x 1 root root 0 Jun 29 13:46 .dockerenv*
lrwxrwxrwx 1 root root 7 Oct 6 2021 bin -> usr/bin/
drwxr-xr-x 2 root root 4096 Apr 15 2020 boot/
drwxr-xr-x 5 root root 360 Jun 29 13:46 dev/
drwxr-xr-x 1 root root 4096 Jun 29 13:46 etc/
drwxr-xr-x 2 root root 4096 Apr 15 2020 home/
lrwxrwxrwx 1 root root 7 Oct 6 2021 lib -> usr/lib/
lrwxrwxrwx 1 root root 9 Oct 6 2021 lib32 -> usr/lib32/
lrwxrwxrwx 1 root root 9 Oct 6 2021 lib64 -> usr/lib64/
lrwxrwxrwx 1 root root 10 Oct 6 2021 libx32 -> usr/libx32/
drwxr-xr-x 2 root root 4096 Oct 6 2021 media/
drwxr-xr-x 2 root root 4096 Oct 6 2021 mnt/
drwxr-xr-x 2 root root 4096 Oct 6 2021 opt/
dr-xr-xr-x 215 root root 0 Jun 29 13:46 proc/
drwx------ 2 root root 4096 Oct 6 2021 root/
drwxr-xr-x 5 root root 4096 Oct 6 2021 run/
lrwxrwxrwx 1 root root 8 Oct 6 2021 sbin -> usr/sbin/
drwxr-xr-x 2 root root 4096 Oct 6 2021 srv/
dr-xr-xr-x 13 root root 0 Jun 29 13:46 sys/
drwxrwxrwt 2 root root 4096 Oct 6 2021 tmp/
drwxr-xr-x 13 root root 4096 Oct 6 2021 usr/
drwxr-xr-x 11 root root 4096 Oct 6 2021 var/
root@438af94a059d:/# cd tmp/
root@438af94a059d:/tmp# pwd
/tmp
root@438af94a059d:/tmp# touch a.txt
root@438af94a059d:/tmp# ll
total 8
drwxrwxrwt 1 root root 4096 Jun 29 13:48 ./
drwxr-xr-x 1 root root 4096 Jun 29 13:46 ../
-rw-r--r-- 1 root root 0 Jun 29 13:48 a.txt
root@438af94a059d:/tmp# read escape sequence
[root@node001 ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
438af94a059d ubuntu "/bin/bash" 5 minutes ago Up 5 minutes reverent_poitras
3fdf86ecd5d1 redis:6.0.8 "docker-entrypoint.s…" 57 minutes ago Up 57 minutes 6379/tcp angry_lewin
[root@node001 ~]# docker cp 438af94a059d:/tmp/a.txt /opt/dataSuccessfully copied 1.54kB to /opt/data
[root@node001 ~]#
[root@node001 ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
438af94a059d ubuntu "/bin/bash" 8 minutes ago Up 8 minutes reverent_poitras
3fdf86ecd5d1 redis:6.0.8 "docker-entrypoint.s…" About an hour ago Up About an hour 6379/tcp angry_lewin
[root@node001 ~]# docker export 438af94a059d > /opt/docker/test001.tar
[root@node001 ~]# docker rm-f 438af94a059d
docker: 'rm-f' is not a docker command.
See 'docker --help'
[root@node001 ~]# docker rm -f 438af94a059d
438af94a059d
[root@node001 ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3fdf86ecd5d1 redis:6.0.8 "docker-entrypoint.s…" About an hour ago Up About an hour 6379/tcp angry_lewin
[root@node001 ~]# cd /opt/docker/
[root@node001 docker]# ll
总用量 73404
-rw-r--r-- 1 root root 75158016 6月 29 21:57 test001.tar
[root@node001 docker]# cd ../
[root@node001 opt]# cat docker/test001.tar | docker import - atguigu/ubuntu:3.7
sha256:7b40f602c17835d8c9fc8315da7e8080b0e7d374b6e60be261d35315487647ef
[root@node001 opt]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3fdf86ecd5d1 redis:6.0.8 "docker-entrypoint.s…" About an hour ago Up About an hour 6379/tcp angry_lewin
[root@node001 opt]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
atguigu/ubuntu 3.7 7b40f602c178 22 seconds ago 72.8MB
hello-world <none> 9c7a54a9a43c 7 weeks ago 13.3kB
ubuntu latest ba6acccedd29 20 months ago 72.8MB
hello-world latest feb5d9fea6a5 21 months ago 13.3kB
redis 6.0.8 16ecd2772934 2 years ago 104MB
[root@node001 opt]# docker run -it 7b40f602c178 /bin/bash
root@70f68fe327a6:/# cd tmp/
root@70f68fe327a6:/tmp# ll
total 8
drwxrwxrwt 2 root root 4096 Jun 29 13:48 ./
drwxr-xr-x 1 root root 4096 Jun 29 14:01 ../
-rw-r--r-- 1 root root 0 Jun 29 13:48 a.txt
root@70f68fe327a6:/tmp#
- attach Attach to a running container # 当前 shell 下 attach 连接指定运行镜像
- build Build an image from a Dockerfile # 通过 Dockerfile 定制镜像
- commit Create a new image from a container changes # 提交当前容器为新的镜像
- cp Copy files/folders from the containers filesystem to the host path #从容器中拷贝指定文件或者目录到宿主机中
- create Create a new container # 创建一个新的容器,同 run,但不启动容器
- diff Inspect changes on a container's filesystem # 查看 docker 容器变化
- events Get real time events from the server # 从 docker 服务获取容器实时事件
- exec Run a command in an existing container # 在已存在的容器上运行命令
- export Stream the contents of a container as a tar archive # 导出容器的内容流作为一个 tar 归档文件[对应 import ]
- history Show the history of an image # 展示一个镜像形成历史
- images List images # 列出系统当前镜像
- import Create a new filesystem image from the contents of a tarball # 从tar包中的内容创建一个新的文件系统映像[对应export]
- info Display system-wide information # 显示系统相关信息
- inspect Return low-level information on a container # 查看容器详细信息
- kill Kill a running container # kill 指定 docker 容器
- load Load an image from a tar archive # 从一个 tar 包中加载一个镜像[对应 save]
- login Register or Login to the docker registry server # 注册或者登陆一个 docker 源服务器
- logout Log out from a Docker registry server # 从当前 Docker registry 退出
- logs Fetch the logs of a container # 输出当前容器日志信息
- port Lookup the public-facing port which is NAT-ed to PRIVATE_PORT # 查看映射端口对应的容器内部源端口
- pause Pause all processes within a container # 暂停容器
- ps List containers # 列出容器列表
- pull Pull an image or a repository from the docker registry server # 从docker镜像源服务器拉取指定镜像或者库镜像
- push Push an image or a repository to the docker registry server # 推送指定镜像或者库镜像至docker源服务器
- restart Restart a running container # 重启运行的容器
- rm Remove one or more containers # 移除一个或者多个容器
- rmi Remove one or more images # 移除一个或多个镜像[无容器使用该镜像才可删除,否则需删除相关容器才可继续或 -f 强制删除]
- run Run a command in a new container # 创建一个新的容器并运行一个命令
- save Save an image to a tar archive # 保存一个镜像为一个 tar 包[对应 load]
- search Search for an image on the Docker Hub # 在 docker hub 中搜索镜像
- start Start a stopped containers # 启动容器
- stop Stop a running containers # 停止容器
- tag Tag an image into a repository # 给源中镜像打标签
- top Lookup the running processes of a container # 查看容器中运行的进程信息
- unpause Unpause a paused container # 取消暂停容器
- version Show the docker version information # 查看 docker 版本号
- wait Block until a container stops, then print its exit code # 截取容器停止时的退出状态值