文章目录
一、上传至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