Docker上传镜像至docker仓库及阿里云仓库

本文详细介绍了如何将Docker镜像上传至公共的Dockerhub仓库以及阿里云的镜像仓库。首先,通过docker login命令登录账号,然后使用docker push命令推送镜像。接着,在阿里云控制台创建镜像仓库,登录并推送镜像。最后,演示了删除本地镜像及从仓库重新拉取的操作。整个过程涵盖了镜像的管理与部署。
摘要由CSDN通过智能技术生成


一、上传至docker仓库

1、登录docker hub创建自己的仓库地址:
https://hub.docker.com/repository/create
创建时,仓库名称要与镜像名称对应

1. 登录账号

docker login -h

# docker login -h
Flag shorthand -h has been deprecated, please use --help

Usage:  docker login [OPTIONS] [SERVER]

Log in to a Docker 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

# docker login -u ivesgdidf

Password: 
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

Login Succeeded

推送镜像到仓库


# docker images                           ##提前查下有可以上传docker仓库的镜像
REPOSITORY                                     TAG        IMAGE ID       CREATED         SIZE
ivesgdidf/nginx                                     latest     5078a81c9281   12 hours ago    247MB

# docker push ivesgdidf/nginx:latest

The push refers to repository [docker.io/ivesgdidf/nginx]
86c59fc311ce: Pushed 
e9361e56c9ab: Pushed 
9bfb731f8dca: Pushed 
e2c21e0914cf: Pushed 
2653d992f4ef: Mounted from library/centos 
latest: digest: sha256:0b9ac0bd34a6a03526cacc60f360a37e456f72c80af63421be0bcc693ef972e1 size: 1363

登录仓库查看镜像推送结果

在这里插入图片描述
在这里插入图片描述


删除本地镜像,再从仓库获取镜像

在这里插入图片描述


二 、上传至阿里云仓库

阿里云: https://cr.console.aliyun.com/cn-hangzhou/mirrors

创建镜像仓库

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述


登录阿里云-镜像命名空间

要先设备下仓库密码,不是跟云账号共用的
在这里插入图片描述

#docker login --username=风云笑gg registry.cn-hangzhou.aliyuncs.com

Password: 
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

Login Succeeded

docker tag nginx:v1 registry.cn-hangzhou.aliyuncs.com/ivesgdidf/nginx:latest
docker images
在这里插入图片描述

上传镜像

docker push registry.cn-hangzhou.aliyuncs.com/ivesgdidf/nginx

Using default tag: latest
The push refers to repository [registry.cn-hangzhou.aliyuncs.com/ivesgdidf/nginx]
86c59fc311ce: Pushed 
e9361e56c9ab: Pushed 
9bfb731f8dca: Pushed 
e2c21e0914cf: Pushed 
2653d992f4ef: Pushed 
latest: digest: sha256:0b9ac0bd34a6a03526cacc60f360a37e456f72c80af63421be0bcc693ef972e1 size: 1363

在这里插入图片描述

再次删除,重新拉取镜像

docker rmi registry.cn-hangzhou.aliyuncs.com/ivesgdidf/nginx

Untagged: registry.cn-hangzhou.aliyuncs.com/ivesgdidf/nginx:latest
Untagged: registry.cn-hangzhou.aliyuncs.com/ivesgdidf/nginx@sha256:0b9ac0bd34a6a03526cacc60f360a37e456f72c80af63421be0bcc693ef972e1

docker pull registry.cn-hangzhou.aliyuncs.com/ivesgdidf/nginx

# docker pull registry.cn-hangzhou.aliyuncs.com/ivesgdidf/nginx

Using default tag: latest
latest: Pulling from ivesgdidf/nginx
Digest: sha256:0b9ac0bd34a6a03526cacc60f360a37e456f72c80af63421be0bcc693ef972e1
Status: Downloaded newer image for registry.cn-hangzhou.aliyuncs.com/ivesgdidf/nginx:latest
registry.cn-hangzhou.aliyuncs.com/ivesgdidf/nginx:latest
[root@localhost ives]# docker images
REPOSITORY                                               TAG        IMAGE ID       CREATED         SIZE
ivesgdidf/nginx                                          latest     5078a81c9281   15 hours ago    247MB
nginx                                                    v1         5078a81c9281   15 hours ago    247MB
registry.cn-hangzhou.aliyuncs.com/ivesgdidf/nginx        latest     5078a81c9281   15 hours ago    247MB

参考:

https://www.cnblogs.com/caijunchao/p/13341080.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

ives

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值