[root@test001 ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE mariadb 10.236837551a279 3 weeks ago 340MB hello-world latest bf756fb1ae65 9 months ago 13.3kB
#解释 REPOSITORY 仓库的名称 TAG 标签 IMAGE ID 镜像的ID CREATED 创建的时间 SIZE 镜像的大小
# docker images 的可选项 可以使用 --help打开可选项帮助
Options: -a, --all Show all images (default hides intermediate images) #查看所有的镜像 --digests Show digests #摘要 -f, --filterfilterFilter output based on conditions provided #根据条件过滤 --format string Pretty-print images using a Go template #格式化 --no-trunc Don't truncate output #截断 -q, --quiet Only show numeric IDs # 只显示镜像的ID
Docker搜索镜像 docker search 搜索的镜像信息
1 2 3 4 5 6 7 8 9 10
Search the Docker Hub for images
Options: -f, --filterfilterFilter output based on conditions provided #根据过滤信息搜索 --format string Pretty-print search using a Go template #格式化 --limit int Max number of search results (default 25) #对搜索的结果进行限制 --no-trunc Don't truncate output #不对结果进行截断 #例如:要搜索被Stars 3000以上的 docker search mysql -f=STARS=3000
#测试 启动并进入容器 root@again:~# docker run -it centos /bin/bash [root@6e8937399257 /]# ls bin dev etc home lib lib64 lost+found media mnt opt proc root run sbin srv sys tmp usr var #退出这个容器 [root@6e8937399257 /]# exit exit root@again:~#
#列出所有运行的容器 root@again:~# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 4b7005ca94a6 mariadb:10.2"docker-entrypoint.s…"6 weeks ago Up 13 days 0.0.0.0:7021->3306/tcp trojan-mariadb #查询所有运行的容器 root@again:~# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 6e8937399257 centos "/bin/bash"3 minutes ago Exited (0) About a minute ago festive_stonebraker 4cb852419d9d centos "/bin/bash"3 minutes ago Exited (127) 3 minutes ago charming_varahamihira e3dc2e75a462 hello-world"/hello"4 minutes ago Exited (0) 4 minutes ago wonderful_archimedes a83c0a6b6e36 hello-world"/hello"4 days ago Exited (0) 4 days ago brave_payne 61dc28dad2a0 hello-world"/hello"4 days ago Exited (0) 4 days ago pensive_burnell 4b7005ca94a6 mariadb:10.2"docker-entrypoint.s…"6 weeks ago Up 13 days 0.0.0.0:7021->3306/tcp trojan-mariadb root@again:~# # 根据条件显示运行的容器 root@again:~# docker ps -a -n=1 CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 6e8937399257 centos "/bin/bash"6 minutes ago Exited (0) 4 minutes ago festive_stonebraker
[root@fugui001 ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE sky0429/java final fa6c155ac43c 15 minutes ago 669MB sky0429/java test fa6c155ac43c 15 minutes ago 669MB sky0429/spark final 864cade88d71 39 minutes ago 939MB sky0429/spark 1.0 5e6a1433e9cc About an hour ago 928MB centos latest 300e315adb2f 3 weeks ago 209MB [root@fugui001 ~]# docker tag sky0429/spark:1.0 sky0429/spark:2.0 [root@fugui001 ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE sky0429/java final fa6c155ac43c 15 minutes ago 669MB sky0429/java test fa6c155ac43c 15 minutes ago 669MB sky0429/spark final 864cade88d71 39 minutes ago 939MB sky0429/spark 1.0 5e6a1433e9cc About an hour ago 928MB sky0429/spark 2.0 5e6a1433e9cc About an hour ago 928MB centos latest 300e315adb2f 3 weeks ago 209MB [root@fugui001 ~]#
修改容器名称
1 2 3 4 5 6 7 8 9 10
# 语法为: docker rename 容器ID 新的容器名
[root@fugui001 ~]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 3c9a8225f928 004894834ce7 "/bin/bash" 8 minutes ago Exited (127) 8 minutes ago romantic_kalam [root@fugui001 ~]# docker rename 3c9a8225f928 test [root@fugui001 ~]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 3c9a8225f928 004894834ce7 "/bin/bash" 8 minutes ago Exited (127) 8 minutes ago test [root@fugui001 ~]#