Docker Push是Docker的一个命令,用于将本地的Docker镜像推送到仓库中。
总之,公有仓库和私有仓库各有优缺点,用户可以根据实际需求选择适合自己的仓库类型。
docker push [OPTIONS] NAME[:TAG]
参数 | 描述 |
---|---|
–disable-content-trust | 禁用内容信任,不对推送的镜像进行签名。 |
–platform | 指定要推送的镜像所在的平台。 |
注册地址: https://hub.docker.com/
[root@docker ~]# docker login
Log in with your Docker ID or email address to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com/ to create one.
You can log in with your password or a Personal Access Token (PAT). Using a limited-scope PAT grants better security and is required for organizations using SSO. Learn more at https://docs.docker.com/go/access-tokens/
Username: circledba
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
[root@docker ~]#
[root@docker ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
cirlce/ubuntu 1.0 4eac314fbf24 5 hours ago 72.8MB
mysql 5.6 dd3b2a5dcb48 23 months ago 303MB
ubuntu latest ba6acccedd29 2 years ago 72.8MB
hello-world latest feb5d9fea6a5 2 years ago 13.3kB
[root@docker ~]# [root@docker ~]# docker tag cirlce/ubuntu:1.0 circledba/kingbase-es:test
[root@docker ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
circledba/kingbase-es test 4eac314fbf24 5 hours ago 72.8MB
cirlce/ubuntu 1.0 4eac314fbf24 5 hours ago 72.8MB
mysql 5.6 dd3b2a5dcb48 23 months ago 303MB
ubuntu latest ba6acccedd29 2 years ago 72.8MB
hello-world latest feb5d9fea6a5 2 years ago 13.3kB
[root@docker ~]#
[root@docker ~]# docker push circledba/kingbase-es:test
The push refers to repository [docker.io/circledba/kingbase-es]
9f54eef41275: Mounted from library/ubuntu
test: digest: sha256:1dec09d8edcd108ab0d17dc25f2c729790118c2f91512b5e492bd646c45a1051 size: 529
[root@docker ~]#
在这已经看到我们推送成功了
[root@docker ~]# docker logout
Removing login credentials for https://index.docker.io/v1/
[root@docker ~]#
[root@docker ~]# docker login [email protected] 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
[root@docker ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
circledba/kingbase-es test 4eac314fbf24 6 hours ago 72.8MB
cirlce/ubuntu 1.0 4eac314fbf24 6 hours ago 72.8MB
mysql 5.6 dd3b2a5dcb48 23 months ago 303MB
ubuntu latest ba6acccedd29 2 years ago 72.8MB
hello-world latest feb5d9fea6a5 2 years ago 13.3kB
[root@docker ~]#
[root@docker ~]# docker tag 4eac314fbf24 registry.cn-hangzhou.aliyuncs.com/circle2023/kingbase-es:test
[root@docker ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
circledba/kingbase-es test 4eac314fbf24 6 hours ago 72.8MB
cirlce/ubuntu 1.0 4eac314fbf24 6 hours ago 72.8MB
registry.cn-hangzhou.aliyuncs.com/circle2023/kingbase-es test 4eac314fbf24 6 hours ago 72.8MB
mysql 5.6 dd3b2a5dcb48 23 months ago 303MB
ubuntu latest ba6acccedd29 2 years ago 72.8MB
hello-world latest feb5d9fea6a5 2 years ago 13.3kB
[root@docker ~]#
[root@docker ~]# docker push registry.cn-hangzhou.aliyuncs.com/circle2023/kingbase-es:test
The push refers to repository [registry.cn-hangzhou.aliyuncs.com/circle2023/kingbase-es]
9f54eef41275: Pushed
test: digest: sha256:1dec09d8edcd108ab0d17dc25f2c729790118c2f91512b5e492bd646c45a1051 size: 529
[root@docker ~]#
在这已经看到我们推送成功了
[root@docker ~]# docker logout registry.cn-hangzhou.aliyuncs.com
Removing login credentials for registry.cn-hangzhou.aliyuncs.com
[root@docker ~]#
[root@docker ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
cirlce/ubuntu 1.0 4eac314fbf24 7 hours ago 72.8MB
registry.cn-hangzhou.aliyuncs.com/circle2023/kingbase-es test 4eac314fbf24 7 hours ago 72.8MB
circledba/kingbase-es test 4eac314fbf24 7 hours ago 72.8MB
mysql 5.6 dd3b2a5dcb48 23 months ago 303MB
ubuntu latest ba6acccedd29 2 years ago 72.8MB
hello-world latest feb5d9fea6a5 2 years ago 13.3kB
[root@docker ~]# docker rmi registry.cn-hangzhou.aliyuncs.com/circle2023/kingbase-es:test
Untagged: registry.cn-hangzhou.aliyuncs.com/circle2023/kingbase-es:test
Untagged: registry.cn-hangzhou.aliyuncs.com/circle2023/kingbase-es@sha256:1dec09d8edcd108ab0d17dc25f2c729790118c2f91512b5e492bd646c45a1051
[root@docker ~]#
[root@docker ~]#
[root@docker ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
cirlce/ubuntu 1.0 4eac314fbf24 7 hours ago 72.8MB
circledba/kingbase-es test 4eac314fbf24 7 hours ago 72.8MB
mysql 5.6 dd3b2a5dcb48 23 months ago 303MB
ubuntu latest ba6acccedd29 2 years ago 72.8MB
hello-world latest feb5d9fea6a5 2 years ago 13.3kB
[root@docker ~]# docker pull registry.cn-hangzhou.aliyuncs.com/circle2023/kingbase-es:test
test: Pulling from circle2023/kingbase-es
Digest: sha256:1dec09d8edcd108ab0d17dc25f2c729790118c2f91512b5e492bd646c45a1051
Status: Downloaded newer image for registry.cn-hangzhou.aliyuncs.com/circle2023/kingbase-es:test
registry.cn-hangzhou.aliyuncs.com/circle2023/kingbase-es:test
[root@docker ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
circledba/kingbase-es test 4eac314fbf24 7 hours ago 72.8MB
cirlce/ubuntu 1.0 4eac314fbf24 7 hours ago 72.8MB
registry.cn-hangzhou.aliyuncs.com/circle2023/kingbase-es test 4eac314fbf24 7 hours ago 72.8MB
mysql 5.6 dd3b2a5dcb48 23 months ago 303MB
ubuntu latest ba6acccedd29 2 years ago 72.8MB
hello-world latest feb5d9fea6a5 2 years ago 13.3kB
[root@docker ~]#