目录
1、docker tag标签管理命令
标记本地镜像,将其归入某一仓库。
语法:docker tag SOURCE_IMAGE[:TAG] TARGET_IMAGE[:TAG]
例如:
# 给reids镜像添加标签。
docker tag 1690b63e207f myredis:0.0.1
注意:一个镜像存在多个标签时,如果该镜像还其他标签,则不会真正删除镜像,只是删除该标签的镜像引用。
docker login
语法:docker login [OPTIONS] [SERVER]
Options:
-p, --password string Password
--password-stdin Take the password from stdin
-u, --username string Username
Login to a Docker registry.
如果是登录到docker hup 上,则不需要指定server.
例如:
docker push
语法:docker image push [OPTIONS] NAME[:TAG]
说明:Push an image or a repository to a registry
Options:
--disable-content-trust Skip image signing (default true)
推送到docker hub上
将本地镜像或仓库推送到docker hub 自己创建的仓库上。
liyansheng0309 为 账号。
lys 为自己创建的仓库。
如:将本地仓库liyansheng0309/lys 推送到远程。
docker push liyansheng0309/lys
推送成功
推送到阿里云上
国内好用的镜像仓库:阿里云
先登录:
docker login --username=liyansheng0309 registry.cn-hangzhou.aliyuncs.com
密码为自己设置的仓库访问凭证密码:
推送到阿里云镜像仓库时,需按一下要求进行镜像标签。
开始推送
推送成功后,可以再阿里云仓库镜像版本上看到 上传的镜像:
镜像的导入与导出(打包)
导出
docker save [OPTIONS] IMAGE [IMAGE...]
Save one or more images to a tar archive (streamed to STDOUT by default)
Options:
-o, --output string Write to a file, instead of STDOUT
例如下图:
# 打包 liyansheng0309/lys:myredis-0.1 liyansheng/lys:myredis-0.1 这两个镜像为redis.gz文件
docker save -o redis.gz liyansheng0309/lys:myredis-0.1 liyansheng/lys:myredis-0.1
导入
docker load [OPTIONS]
说明:Load an image from a tar archive or STDIN
Options:
-i, --input string Read from tar archive file, instead of STDIN
-q, --quiet Suppress the load output
例如:
#导入镜像
docker load -i redis.gz
镜像导入导出 存在的缺点:
1、如果本地没有底层镜像的话,在docker run 时,同样会从服务上下载镜像。 所以该操作需事先准备好本地镜像。