Docker上传镜像&拉取镜像
Docker官方镜像仓库网站:https://hub.docker.com/ ,其实我们平时docker pull xxx
就是从该仓库得到的镜像(在不设置国内镜像加速的情况下)
创建账号
Docker Hub:https://hub.docker.com/
注:注册可能需要翻墙
以重新上传一个项目做示范,该镜像是从Docker Hub
上pull
到的一个nginx
镜像,把它上传到自己的公开仓库
上传镜像
首先登录Docker Hub
账号:
# docker login
Login with your Docker ID 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.
Username (yezhou): yezhou
Password:
Login Succeeded
# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/openjdk 8-jre bef23b4b9cac 2 weeks ago 443 MB
docker.io/nginx latest ae513a47849c 4 weeks ago 109 MB
# docker tag docker.io/nginx yezhou/nginx
# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/openjdk 8-jre bef23b4b9cac 2 weeks ago 443 MB
yezhou/nginx latest ae513a47849c 4 weeks ago 109 MB
docker.io/nginx latest ae513a47849c 4 weeks ago 109 MB
# docker push yezhou/nginx
The push refers to a repository [docker.io/yezhou/nginx]
7ab428981537: Mounted from library/nginx
82b81d779f83: Mounted from library/nginx
d626a8ad97a1: Mounted from library/nginx
latest: digest: sha256:e4f0474a75c510f40b37b6b7dc2516241ffa8bde5a442bde3d372c9519c84d90 size: 948
流程大概是:登录
-> tag操作
-> push
注:tag
的第二个参数的前缀是Docker Hub
账户名
拉取镜像
先将本地的镜像删除掉,然后再从Docker Hub
中拉取镜像
# 删除本地yezhou/nginx镜像
# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/openjdk 8-jre bef23b4b9cac 2 weeks ago 443 MB
yezhou/nginx latest ae513a47849c 4 weeks ago 109 MB
docker.io/nginx latest ae513a47849c 4 weeks ago 109 MB
# docker rmi yezhou/nginx
Untagged: yezhou/nginx:latest
Untagged: yezhou/nginx@sha256:e4f0474a75c510f40b37b6b7dc2516241ffa8bde5a442bde3d372c9519c84d90
# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/openjdk 8-jre bef23b4b9cac 2 weeks ago 443 MB
docker.io/nginx latest ae513a47849c 4 weeks ago 109 MB
# 从Docker Hub中拉取yezhou/nginx镜像
# docker pull yezhou/nginx
Using default tag: latest
Trying to pull repository docker.io/yezhou/nginx ...
latest: Pulling from docker.io/yezhou/nginx
Digest: sha256:e4f0474a75c510f40b37b6b7dc2516241ffa8bde5a442bde3d372c9519c84d90
Status: Downloaded newer image for docker.io/yezhou/nginx:latest
# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/openjdk 8-jre bef23b4b9cac 2 weeks ago 443 MB
docker.io/yezhou/nginx latest ae513a47849c 4 weeks ago 109 MB
docker.io/nginx latest ae513a47849c 4 weeks ago 109 MB
版权声明:
作者:Joe.Ye
链接:https://www.appblog.cn/index.php/2023/03/30/docker-uploads-and-pulls-images/
来源:APP全栈技术分享
文章版权归作者所有,未经允许请勿转载。
THE END
0
二维码
打赏
海报
Docker上传镜像&拉取镜像
Docker官方镜像仓库网站:https://hub.docker.com/ ,其实我们平时docker pull xxx就是从该仓库得到的镜像(在不设置国内镜像加速的情况下)
创建账号
Docker ……
文章目录
关闭
共有 0 条评论