运维-docker-镜像仓库

306 阅读1分钟

1 登录/登出镜像仓库

1.1 创建阿里云容器镜像仓库,阿里云搜索容器镜像服务并且开通,需要注意登录时候的密码通过如下路径设置

容器镜像服务->实例列表->访问凭证

image.png

1.2 登录命令

[root@localhost ~]# docker login --help

Usage:  docker login [OPTIONS] [SERVER]

Log in to a registry.
If no server is specified, the default is defined by the daemon.

Options:
  -p, --password string   Password
      --password-stdin    Take the password from stdin
  -u, --username string   Username

1.3 例子:登录阿里云容器镜像仓库

docker login --username=[你的账号] registry.cn-hangzhou.aliyuncs.com

image.png

2 推送镜像到私有仓库

2.1 在阿里云镜像服务中创建私有仓库

image.png

2.2 根据阿里云的提示,进行操作推送

image.png

大致步骤:

  1. 登录私有仓库
  2. 对需要推送的镜像镜像打tag(其实就是改名字和版本),这里已经说明了推送的仓库。
  3. 推送push
  4. 使用pull进行下载,(docker pull 仓库名称:版本)