[root@localhost ~]# docker pull --help Usage: docker pull [OPTIONS] NAME[:TAG|@DIGEST] --DIGEST摘要,镜像内容的哈希值,用来验证内容是否被篡改,和TAG同作用,但TAG更方便 Download an image from a registry --拉取一个仓库 Aliases: docker image pull, docker pull Options: -a, --all-tags Download all tagged images in the repository --下载一个仓库的所有镜像,可能会下载很多东西 --disable-content-trust Skip image verification (default true) --跳过镜像的验证,默认是跳过的,下第三方的时候最好设置成false --platform string Set platform if server is multi-platform --拉去指定架构的镜像,不常用,一般都是和自身架构匹配的 capable -q, --quiet Suppress verbose output --省略下载的输出信息,减少信息冗余
docker images
[root@localhost ~]# docker images --help Usage: docker images [OPTIONS] [REPOSITORY[:TAG]] List images Aliases: docker image ls, docker image list, docker images Options: -a, --all Show all images (default hides intermediate images) --digests Show digests -f, --filter filter Filter output based on conditions provided --format string Format output using a custom template: 'table': Print output in table format with column headers (default) 'table TEMPLATE': Print output in table format using the given Go template 'json': Print in JSON format 'TEMPLATE': Print output using the given Go template. Refer to https://docs.docker.com/go/formatting/ for more information about formatting output with templates --no-trunc Don't truncate output -q, --quiet Only show image IDs
– digests可以查看镜像的摘要
[root@localhost ~]# docker images --digests REPOSITORY TAG DIGEST IMAGE ID CREATED SIZE busybox latest sha256:6d9ac9237a84afe1516540f40a0fafdc86859b2141954b4d643af7066d598b74 3f57d9401f8d 6 weeks ago 4.26MB hello-world latest sha256:d000bc569937abbe195e20322a0bde6b2922d805332fd6d8a68b19f524b7d21d d2c94e258dcb 10 months ago 13.3kB centos 7 sha256:be65f488b7764ad3638f236b7b515b3678369a5124c47b8d32916d6487418ea4 eeb6ee3f44bd 2 years ago 204MB
–no-trunc,写全信息
[root@localhost ~]# docker images --no-trunc REPOSITORY TAG IMAGE ID CREATED SIZE busybox latest sha256:3f57d9401f8d42f986df300f0c69192fc41da28ccc8d797829467780db3dd741 6 weeks ago 4.26MB hello-world latest sha256:d2c94e258dcb3c5ac2798d32e1249e42ef01cba4841c2234249495f87264ac5a 10 months ago 13.3kB centos 7 sha256:eeb6ee3f44bd0b5103bb561b4c16bcb82328cfe5809ab675bb17ab3a16c517c9 2 years ago 204MB
[root@localhost ~]# docker search centos NAME DESCRIPTION STARS OFFICIAL centos DEPRECATED; The official build of CentOS. 7715 [OK] kasmweb/centos-7-desktop CentOS 7 desktop for Kasm Workspaces 43 ...
Options: -f, --filter filter Filter output based on conditions provided -f和之前的images差不多 --format string Pretty-print search using a Go template --limit int Max number of search results-限制个数 --no-trunc Don't truncate output
dockers rmi(删除容器 rm)
[root@localhost ~]# docker rmi --help Usage: docker rmi [OPTIONS] IMAGE [IMAGE...] Remove one or more images Aliases: docker image rm, docker image remove, docker rmi Options: -f, --force Force removal of the image --强制删除 --no-prune Do not delete untagged parents --和镜像层相关
操作一下试试
[root@localhost ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE busybox latest 3f57d9401f8d 6 weeks ago 4.26MB hello-world latest d2c94e258dcb 10 months ago 13.3kB centos 7 eeb6ee3f44bd 2 years ago 204MB [root@localhost ~]# docker rmi centos:7 Untagged: centos:7 Untagged: centos@sha256:be65f488b7764ad3638f236b7b515b3678369a5124c47b8d32916d6487418ea4 Deleted: sha256:eeb6ee3f44bd0b5103bb561b4c16bcb82328cfe5809ab675bb17ab3a16c517c9 Deleted: sha256:174f5685490326fc0a1c0f5570b8663732189b327007e47ff13d2ca59673db02 [root@localhost ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE busybox latest 3f57d9401f8d 6 weeks ago 4.26MB hello-world latest d2c94e258dcb 10 months ago 13.3kB [root@localhost ~]# docker rmi hello-world Error response from daemon: conflict: unable to remove repository reference "hello-world" (must force) - container 9c54e5ac2981 is using its referenced image d2c94e258dcb [root@localhost ~]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 9c54e5ac2981 hello-world "/hello" 6 hours ago Exited (0) 6 hours ago ecstatic_ride 0881099d27ad hello-world "/hello" 20 hours ago Exited (0) 20 hours ago vibrant_murdock [root@localhost ~]# docker rmi -f hello-world Untagged: hello-world:latest Untagged: hello-world@sha256:d000bc569937abbe195e20322a0bde6b2922d805332fd6d8a68b19f524b7d21d Deleted: sha256:d2c94e258dcb3c5ac2798d32e1249e42ef01cba4841c2234249495f87264ac5a [root@localhost ~]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 9c54e5ac2981 d2c94e258dcb "/hello" 7 hours ago Exited (0) 7 hours ago ecstatic_ride 0881099d27ad d2c94e258dcb "/hello" 20 hours ago Exited (0) 20 hours ago vibrant_murdock [root@localhost ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE busybox latest 3f57d9401f8d 6 weeks ago 4.26MB
其中hello-world因为已经运行在容器里了,可以ps -a一下看看,然后用-f强制删除
docker save
用来把镜像打包保存到本体,方变移动
[root@localhost ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE zookeeper 3.7 446078172ae8 2 weeks ago 307MB busybox latest 3f57d9401f8d 6 weeks ago 4.26MB [root@localhost ~]# docker save --help Usage: docker save [OPTIONS] IMAGE [IMAGE...] Save one or more images to a tar archive (streamed to STDOUT by default) Aliases: docker image save, docker save Options: -o, --output string Write to a file, instead of STDOUT [root@localhost ~]# docker save -o my.tar zookeeper:3.7 busybox:latest [root@localhost ~]# ll total 310364 ... -rw-------. 1 root root 317776384 Mar 1 04:01 my.tar ... 也可以重定向到一个文件里,用> [root@localhost ~]# docker save zookeeper:3.7 busybox:latest > new.tar [root@localhost ~]# ll total 620696 ... -rw-------. 1 root root 317776384 Mar 1 04:01 my.tar -rw-r--r--. 1 root root 317776384 Mar 1 04:03 new.tar ...大小都是一样得
这是原来的,然后把它们删除
[root@localhost ~]# docker rmi 446078172ae8 3f57d9401f8d ... [root@localhost ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE
然后再把tar加载出来
docker load
[root@localhost ~]# docker load --help Usage: docker load [OPTIONS] Load an image from a tar archive or STDIN Aliases: docker image load, docker load Options: -i, --input string Read from tar archive file, instead of STDIN -q, --quiet Suppress the load output
[root@localhost ~]# docker pull ubuntu Using default tag: latest latest: Pulling from library/ubuntu 01007420e9b0: Pull complete Digest: sha256:f9d633ff6640178c2d0525017174a688e2c1aef28f0a0130b26bd5554491f0da Status: Downloaded newer image for ubuntu:latest docker.io/library/ubuntu:latest
遇到问题Error docker login—-
Error response from daemon: pull access denied for ubantu, repository does not e xist or may require ‘docker login’: denied: requested access to the resource is denied
docker run --name myubantu ubantu #--name重命名方便查询进程 [root@localhost ~]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 6bb10ad29613 ubuntu "/bin/bash" 4 seconds ago Exited (0) 3 seconds ago myubuntu
docker run --name mybantu2 -it ubuntu /bin/bash #-i是交互式命令,-t是给一个伪客户端, /bin/bash是常用shell的路径 [root@localhost ~]# docker run --name mybuntu2 -it ubuntu /bin/bash root@939a1dcb875c:/# ls bin boot dev etc home lib lib32 lib64 libx32 media mnt opt proc root run sbin srv sys tmp usr var
ctrl + p + q容器还是up的 ctrl + c 就直接退出了 [root@localhost ~]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES b162037cb017 tomcat:8.5.49 "catalina.sh run" 7 minutes ago Up 7 minutes 0.0.0.0:8080->8080/tcp, :::8080->8080/tcp tom1
这里可以发现 command就不是/bin/bash了,俄式一个.sh文件
tips:0.0.0.0 ipv4的任意ip ::: ipv6的任意ip
守护进程方式启动tomcat
但如果伪终端一直存在,对后续的操作并不是很方便,所以我们可以把-it参数换成-d
[root@localhost ~]# docker run --name tom2 -dp 8081:8080 tomcat:8.5.49 e37ef6eeb57e3ef728d06c3807ace699a4292266fe8b295f384a04afc4e28c93
docker exec -it tom3 /bin/bash root@e85341ca6a4a:/usr/local/tomcat# rm -rf webapps root@e85341ca6a4a:/usr/local/tomcat# ls BUILDING.txt NOTICE RUNNING.txt include native-jni-lib work CONTRIBUTING.md README.md bin lib temp LICENSE RELEASE-NOTES conf logs webapps.dist root@e85341ca6a4a:/usr/local/tomcat# mv webapps.dist/ webapps root@e85341ca6a4a:/usr/local/tomcat# ls BUILDING.txt NOTICE RUNNING.txt include native-jni-lib work CONTRIBUTING.md README.md bin lib temp LICENSE RELEASE-NOTES conf logs webapps
现在webapps里面有东西,再重新访问试试,发现可以了
对于高板本的问题,主要是webapps的目录是空的,需要移过去
容器退出命令
docker rm -f $(docker ps -a)强制删除全部容器 [root@localhost ~]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
exit ctrl p + q
docker exec
[root@localhost ~]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES fc32e8b34259 tomcat:8.5.49 "catalina.sh run" 22 minutes ago Up 22 minutes 0.0.0.0:8081->8080/tcp, :::8081->8080/tcp tom [root@localhost ~]# docker exec -it tom /bin/bash root@fc32e8b34259:/usr/local/tomcat# exit exit [root@localhost ~]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES fc32e8b34259 tomcat:8.5.49 "catalina.sh run" 22 minutes ago Up 22 minutes 0.0.0.0:8081->8080/tcp, :::8081->8080/tcp tom
Options: - d, --detach Detached mode: run command in the background --后台运行,分离模式 --detach-keys string Override the key sequence for detaching a container --指定别的快捷键组合替代ctrl p q -e, --env list Set environment variables 设置环境变量 --env-file list Read in a file of environment variables 文件形式配置环境变量 -i, --interactive Keep STDIN open even if not attached 交互方式 --privileged Give extended privileges to the command 扩展特权 -t, --tty 伪客户端 Allocate a pseudo-TTY -u, --user string 有的容器需要身份认证 Username or UID (format: "<name|uid>[:<group|gid>]") -w, --workdir string Working directory inside the container 设置工作目录
[root@localhost ~]# docker exec -it tom ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever 16: eth0@if17: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default link/ether 02:42:ac:11:00:02 brd ff:ff:ff:ff:ff:ff link-netnsid 0 inet 172.17.0.2/16 brd 172.17.255.255 scope global eth0 valid_lft forever preferred_lft forever [root@localhost ~]# docker exec -it tom pwd /usr/local/tomcat
docker attach
和exec类似,但对tomcat有例外,进不去
[root@localhost ~]# docker run --name buntu -it ubuntu /bin/bash root@0c5e1d974b26:/# [root@localhost ~]# [root@localhost ~]# [root@localhost ~]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 0c5e1d974b26 ubuntu "/bin/bash" 17 seconds ago Up 15 seconds buntu fc32e8b34259 tomcat:8.5.49 "catalina.sh run" 42 minutes ago Up 42 minutes 0.0.0.0:8081->8080/tcp, :::8081->8080/tcp tom [root@localhost ~]# docker exec -it buntu /bin/bash root@0c5e1d974b26:/# exit exit [root@localhost ~]# docker attach buntu root@0c5e1d974b26:/# ls bin dev home lib32 libx32 mnt proc run srv tmp var boot etc lib lib64 media opt root sbin sys usr root@0c5e1d974b26:/# exit exit [root@localhost ~]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 0c5e1d974b26 ubuntu "/bin/bash" About a minute ago Exited (0) 9 seconds ago buntu fc32e8b34259 tomcat:8.5.49 "catalina.sh run" 43 minutes ago Up 43 minutes 0.0.0.0:8081->8080/tcp, :::8081->8080/tcp tom
Attach local standard input, output, and error streams to a running container
Aliases: docker container attach, docker attach
Options: --detach-keys string Override the key sequence for detaching a container --no-stdin Do not attach STDIN 键盘输入不起作用,默认false --sig-proxy Proxy all received signals to the process (default true) 接收的信号代理到进程
[root@localhost ~]# docker start buntu buntu [root@localhost ~]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 0c5e1d974b26 ubuntu "/bin/bash" 26 minutes ago Up 3 seconds buntu
因为ubuntu的cmd是bash,是命令行
[root@localhost ~]# docker exec -it tom /bin/bash root@fc32e8b34259:/usr/local/tomcat# cd logs root@fc32e8b34259:/usr/local/tomcat/logs# ls catalina.2024-03-03.log host-manager.2024-03-03.log localhost.2024-03-03.log localhost_access_log.2024-03-03.txt manager.2024-03-03.log root@fc32e8b34259:/usr/local/tomcat/logs# cat localhost_access_log.2024-03-03.txt 192.168.174.1 - - [03/Mar/2024:09:05:56 +0000] "GET / HTTP/1.1" 200 11215
[root@localhost ~]# docker ps --help Usage: docker ps [OPTIONS] List containers Aliases: docker container ls, docker container list, docker container ps, docker ps Options: -a, --all Show all containers (default shows just running) -f, --filter filter Filter output based on conditions provided 过滤条件 --format string Format output using a custom template: 格式化输出 'table': Print output in table format with column headers (default) 'table TEMPLATE': Print output in table format using the given Go template 'json': Print in JSON format 'TEMPLATE': Print output using the given Go template. Refer to https://docs.docker.com/go/formatting/ for more information about formatting output with templates -n, --last int Show n last created containers (includes all states) (default -1) 显示n个容器 -l, --latest Show the latest created container (includes all states) 显示最后一个创建的容器 --no-trunc Don't truncate output 完整显示输出 -q, --quiet Only display container IDs -s, --size Display total file sizes
docker top
[root@localhost ~]# docker ps 默认显示正在运行的容器 CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES fc32e8b34259 tomcat:8.5.49 "catalina.sh run" 6 hours ago Up About an hour 0.0.0.0:8081->8080/tcp, :::8081->8080/tcp tom [root@localhost ~]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 0c5e1d974b26 ubuntu "/bin/bash" 6 hours ago Exited (0) 5 hours ago buntu fc32e8b34259 tomcat:8.5.49 "catalina.sh run" 6 hours ago Up About an hour 0.0.0.0:8081->8080/tcp, :::8081->8080/tcp tom [root@localhost ~]# docker top tom UID PID PPID C STIME TTY TIME CMD root 14342 14323 0 20:37 pts/0 00:00:07 /usr/local/openjdk-8/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Dorg.apache.catalina.security.SecurityListener.UMASK=0027 -Dignore.endorsed.dirs= -classpath /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar -Dcatalina.base=/usr/local/tomcat -Dcatalina.home=/usr/local/tomcat -Djava.io.tmpdir=/usr/local/tomcat/temp org.apache.catalina.startup.Bootstrap start [root@localhost ~]# docker top tom1 UID PID PPID C STIME TTY TIME CMD root 16306 16287 0 21:54 pts/0 00:00:00 /bin/bash
Options: --details Show extra details provided to logs -f, --follow Follow log output --since string Show logs since timestamp (e.g. "2013-01-02T13:23:37Z") or relative (e.g. "42m" for 42 minutes) -n, --tail string Number of lines to show from the end of the logs (default "all") -t, --timestamps Show timestamps --until string Show logs before a timestamp (e.g. "2013-01-02T13:23:37Z") or relative (e.g. "42m" for 42 minutes) docker logs --since "2024-03-04" --tail 3 buntu 这里的日期也可以换成10s,10h,since也可以换成until docker logs -f -n 10 tom 这个f可以用来查看容器动态的日志
Copy files/folders between a container and the local filesystem
Use '-' 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 cp
Options: -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@localhost worksp]# ls my.tar new.tar test.c [root@localhost worksp]# docker cp my.tar buntu:/root Successfully copied 318MB to buntu:/root [root@localhost worksp]# docker exec -it buntu /bin/bash root@0c5e1d974b26:/# cd /root root@0c5e1d974b26:~# ls my.tar
Usage: docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]] tag叫什么都行,如果这个repository和tag都没有命名,默认是null,就成悬虚镜像了 Create a new image from a container's changes
Aliases: docker container commit, docker commit
Options: -a, --author string Author (e.g., "John Hannibal Smith <hannibal@a-team.com>")作者 -c, --change list Apply Dockerfile instruction to the created image 可以增加指令,不常用 -m, --message string Commit message提交 -p, --pause Pause container during commit (default true) 暂停容器,up->暂停,默认时true
例子:
[root@localhost ~]# docker commit -a "youzipii <123@163.com>" -m "Added net-tools" ct1 centos7:net-tools sha256:ee655f40750fcdbee0c3fac1b6f7ffdf2b19c862bf4d4c7a0e52fc8930d52e01 [root@localhost ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE centos7 net-tools ee655f40750f 9 seconds ago 445MB [root@localhost ~]# docker inspect ee655f40750f可以看详细信息元数据 开起来看看有没有net-tools [root@localhost ~]# docker run --name ct2 -it centos7:net-tools [root@c789c7b87faa /]# ifconfig eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 172.17.0.2 netmask 255.255.0.0 broadcast 172.17.255.255
tips:删除悬虚镜像
[root@localhost ~]# docker image prune WARNING! This will remove all dangling images. Are you sure you want to continue? [y/N] y Deleted Images: deleted: sha256:6c0ad715431faaa5ef68eecdc2a3cd489b66b6a765fb43775bb5376179d54138 Total reclaimed space: 0B
容器导入导出
导出xport
[root@localhost ~]# docker export --help
Usage: docker export [OPTIONS] CONTAINER
Export a container's filesystem as a tar archive
Aliases: docker container export, docker export
Options: -o, --output string Write to a file, instead of STDOUT
[root@localhost ~]# docker export -o tom1-ex.tar tom1 [root@localhost ~]# ls anaconda-ks.cfg Downloads mycmd Public Videos Desktop initial-setup-ks.cfg original-ks.cfg Templates worksp Documents Music Pictures tom1-ex.tar
Import the contents from a tarball to create a filesystem image
Aliases: docker image import, docker import
Options: -c, --change list Apply Dockerfile instruction to the created image -m, --message string Set commit message for imported image --platform string Set platform if server is multi-platform capable
[root@localhost ~]# docker import tom1-ex.tar tom8:import sha256:3c91db73c82f48199d9cb1c805d9f80c1da963736217573d33228067e50395f3 [root@localhost ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE tom8 import 3c91db73c82f 4 seconds ago 499MB tomcat 8.5.49 6408fdc94212 4 years ago 507MB
Commands: df Show docker disk usage 查看当前磁盘使用情况 events Get real time events from the server info Display system-wide information prune Remove unused data
Run 'docker system COMMAND --help'for more information on a command.
df
[youzipii@localhost ~]$ docker system df --help
Usage: docker system df [OPTIONS]
Show docker disk usage
Options: --format string Format output using a custom template: 'table': Print output in table format with column headers (default) 'table TEMPLATE': Print output in table format using the given Go template 'json': Print in JSON format 'TEMPLATE': Print output using the given Go template. Refer to https://docs.docker.com/go/formatting/ for more information about formatting output with templates -v, --verbose Show detailed information on space usage [root@localhost ~]# docker system df TYPE TOTAL ACTIVE SIZE RECLAIMABLE Images 10 4 2.784GB 2.036GB (73%) Containers 5 0 559.3MB 559.3MB (100%) Local Volumes 0 0 0B 0B Build Cache 0 0 0B 0B
docker system enents
[root@localhost ~]# docker system events --help
Usage: docker system events [OPTIONS]
Get real time events from the server
Aliases: docker system events, docker events
Options: -f, --filter filter Filter output based on conditions provided --format string Format output using a custom template: 'json': Print in JSON format 'TEMPLATE': Print output using the given Go template. Refer to https://docs.docker.com/go/formatting/ for more information about formatting output with templates --since string Show all events created since timestamp --until string Stream events until this timestamp docker system events 2024-03-15T15:36:48.294313459+08:00 container create 5933b54ec9d2b725ff3b3350804c6ea2919272829651e45097d46ac5826806ee (image=tomcat:8.5.49, name=tom2)
有点像日志监视器,有容器启停之类 的信息它会输出在这里
docker system info
[root@localhost ~]# docker system info Client: Docker Engine - Community Version: 25.0.3 Context: default Debug Mode: false Plugins: buildx: Docker Buildx (Docker Inc.) Version: v0.12.1 ... docker info也行
docker system prune(重点)
[root@localhost ~]# docker system prune --help
Usage: docker system prune [OPTIONS]
Remove unused data
Options: -a, --all Remove all unused images not just dangling ones 一出所有没在使用的镜像 --filter filter Provide filter values (e.g. "label=<key>=<value>") -f, --force Do not prompt for confirmation --volumes Prune anonymous volumes [root@localhost ~]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 5933b54ec9d2 tomcat:8.5.49 "/bin/bash" 5 minutes ago Exited (0) 5 minutes ago tom2 fc32e8b34259 tomcat:8.5.49 "catalina.sh run" 12 days ago Up 11 minutes 0.0.0.0:8081->8080/tcp, :::8081->8080/tcp tom [root@localhost ~]# docker system prune WARNING! This will remove: - all stopped containers - all networks not used by at least one container - all dangling images - unused build cache
Are you sure you want to continue? [y/N] y Deleted Containers: 5933b54ec9d2b725ff3b3350804c6ea2919272829651e45097d46ac5826806ee
Total reclaimed space: 5B [root@localhost ~]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES fc32e8b34259 tomcat:8.5.49 "catalina.sh run" 12 days ago Up 11 minutes 0.0.0.0:8081->8080/tcp, :::8081->8080/tcp tom
另外,还有一个命令 docker system prune 也可以删除悬虚镜像。只不过,其不仅删除的是悬虚镜像,还有其它系统“无用”内容。。 在删除这个悬虚镜像之前,首先查看其是否启动了容器。如果启动了,则先将容器删除。”
docke system/image prune
docker network
docker0 实现容器互相通信以及容器和宿主机互相通信
docker network ls
查看所有网络
NETWORK ID NAME DRIVER SCOPE 6e6425c662ac bridge bridge local 293407e0c5ce cve-2017-10271_default bridge local 743e5e15a2d5 host host local 1ba283749203 none null local