(Docker notes): Basic commands for Docker mirroring

table of Contents

Basic commands of Docker image

Help command

docker images mirroring command

docker search mirror search

docker pull download image

Specified version download

docker rmi delete mirror


Basic commands of Docker image

Help command

docker version        # 显示docker版本信息
docker info           # docker的系统信息,包括镜像和容器的数量
docker 命令 --help    # 帮助命令

docker images mirroring command

  • View all mirrors on the local host
docker images [OPTIONS] [REPOSITORY[:TAG]]
Name, shorthand Description
--all , -a Show all images (default hides intermediate images)
--digests Show digests
--filter , -f Filter output based on conditions provided
--format Pretty-print images using a Go template
--no-trunc Don’t truncate output
--quiet , -q Only show numeric IDs
  • Or use the help command

-a, --all               列出所有镜像
      --digests         显示摘要
-f, --filter filter     根据提供的条件过滤输出
      --format string   指定返回值的模板文件
      --no-trunc        不截断输出,显示完整的镜像信息
-q, --quiet             只显示镜像ID

  • parameter:
REPOSITORY Mirrored repository source
TAG Mirrored label
IMAGE ID Mirror id
CREATED Mirror creation time
SIZE Mirror size

docker search mirror search

  • Search with docker search in Linux command line

Options:

Name, shorthand default description
--automated   Deprecated
Only show automatic build
--filter , -f   Filter the output according to the provided conditions
--format   Use Go templates for print search
--limit 25 Maximum number of search results
--no-trunc   Don't truncate the output
--stars , -s   Not recommended,
only show at least x stars
  • For example :
    • Filter the search results by favorites or others --filter=stars=3000 (The searched mirrors are those with STARS greater than 3000)

docker pull download image

# 下载镜像 docker pull 镜像名[:tag]  
# tag可以指定版本,没有的话默认使用最新版
[root@admin ~]# docker pull mysql
Using default tag: latest     # 如果不写tag 默认就是最新版
latest: Pulling from library/mysql
d121f8d1c412: Pull complete   # 分层下载,docker image 的核心,联合文件系统
f3cebc0b4691: Pull complete 
1862755a0b37: Pull complete 
489b44f3dbb4: Pull complete 
690874f836db: Pull complete 
baa8be383ffb: Pull complete 
55356608b4ac: Pull complete 
dd35ceccb6eb: Pull complete 
429b35712b19: Pull complete 
162d8291095c: Pull complete 
5e500ef7181b: Pull complete 
af7528e958b6: Pull complete 
Digest: sha256:e1bfe11693ed2052cb3b4e5fa356c65381129e87e38551c6cd6ec532ebe0e808# 签名信息
Status: Downloaded newer image for mysql:latest
docker.io/library/mysql:latest  # 真实地址 

# docker pull mysql 
# docker pull docker.io/library/mysql:latest 
# 两者等价的

Specified version download

  • The version must exist, you can see on docker hub

# 指定版本下载 版本不可乱写 可在 docker hub 上查看
[root@admin ~]# docker pull mysql:5.7  # 加上了tag标签后可指定版本下载
5.7: Pulling from library/mysql
d121f8d1c412: Already exists  # 可以看到这里会显示一些文件已存在
f3cebc0b4691: Already exists  # 这就是分层下载的好处 可以共用一些文件
1862755a0b37: Already exists 
489b44f3dbb4: Already exists 
690874f836db: Already exists 
baa8be383ffb: Already exists 
55356608b4ac: Already exists 
277d8f888368: Pull complete 
21f2da6feb67: Pull complete 
2c98f818bcb9: Pull complete 
031b0a770162: Pull complete 
Digest: sha256:14fd47ec8724954b63d1a236d2299b8da25c9bbb8eacc739bb88038d82da4919
Status: Downloaded newer image for mysql:5.7
docker.io/library/mysql:5.7

docker rmi delete mirror

  • Can be deleted by IMAGE ID, or according to the image name
# 删除指定id的镜像
docker rmi -f 容器id  
# 删除多个镜像
docker rmi -f 容器id 容器id 容器id 
# 删除全部镜像
docker rmi -f $(docker images -aq)

Guess you like

Origin blog.csdn.net/baidu_41388533/article/details/108534404