DockerHub 镜像仓库(5)

之前我们使用的镜像都是从 DockerHub 公共仓库拉取的,我们也学习了如何制作自己的镜像,但是通过 tar 包的方式实现镜像的备份恢复迁移对于团队协作开发并不是特别友好,我们也可以将镜像推送至 DockerHub 仓库方便使用。
温馨提示:如果构建的镜像内携带了项目数据,建议还是使用私有仓库比较好。

1. 注册账号

官网:https://hub.docker.com/

2. shell 命令登入

通过 docker login 命令输入账号密码登录 DockerHub。

3. 推送镜像至仓库

为了方便测试,我们将 hello-world 镜像拉取至本地,然后再上传至 DockerHub 仓库中。
先给镜像设置标签 docker tag local-image:tagname new-repo:tagname ;
再将镜像推送至仓库 docker push new-repo:tagname 。

docker tag hello-world:latest xxxx/test-hello-world:1.0.0
docker push xxxx/test-hello-world:1.0.0

4. 拉取镜像

通过 docker pull xxxx/test-hello-world:1.0.0 测试镜像是否可以拉取。

5. 退出账号

通过 docker logout 命令退出 DockerHub。

[root@localhost ~]# docker logout
Removing login credentials for https://index.docker.io/v1/
posted @ 2022-04-20 22:19  shenghuotaiai  阅读(84)  评论(0编辑  收藏  举报