019、使用公共Registry (2019-01-10 周四)

 
在DockerHub上注册一个账号,这样就可以将自己构建的镜像上传到DockerHub上供别人使用了,公共Registry是免费的,也可以使用付费的私有Registry。
 
root@docker-lab:~/019# docker build -t test019 .    #    构建一个测试镜像
Sending build context to Docker daemon  2.048kB
Step 1/2 : FROM busybox
latest: Pulling from library/busybox
57c14dd66db0: Pull complete
Digest: sha256:7964ad52e396a6e045c39b5a44438424ac52e12e4d5a25d94895f2058cb863a0
Status: Downloaded newer image for busybox:latest
---> 3a093384ac30
Step 2/2 : CMD echo "Hello www1707"
---> Running in 7d7793d50385
Removing intermediate container 7d7793d50385
---> fe57f4f69c44
Successfully built fe57f4f69c44
Successfully tagged test019:latest
 
root@docker-lab:~/019# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
test019             latest              fe57f4f69c44        21 minutes ago      1.2MB
busybox             latest              3a093384ac30        9 days ago          1.2MB
 
root@docker-lab:~/019# docker tag test019:latest www1707/test:v1.9.1    #    使用docker tag 命令让刚构建的镜像与Docker Hub账号匹配
 
root@docker-lab:~/019# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
test019             latest              fe57f4f69c44        30 minutes ago      1.2MB
www1707/test        v1.9.1              fe57f4f69c44        30 minutes ago      1.2MB
busybox             latest              3a093384ac30        9 days ago          1.2MB
 
root@docker-lab:~/019# docker login -u www1707    #    登录DockerHub
Password:
Login Succeeded
 
root@docker-lab:~/019# docker push www1707/test:v1.9.1    #    上传镜像
The push refers to repository [docker.io/www1707/test]
683f499823be: Mounted from library/busybox
v1.9.1: digest: sha256:54ae599930613f4ac8d84f024bcad300727d39fccb43d80086169ce30ba66680 size: 527
 
 
root@docker-lab:~/019# docker images -a
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZ
root@docker-lab:~/019# docker pull www1707/test:v1.9.1
v1.9.1: Pulling from www1707/test
57c14dd66db0: Pull complete
Digest: sha256:5af948aea202288c12f93cbb3de383510649704f2f954b7cb5cf59102874a321
Status: Downloaded newer image for www1707/test:v1.9.1
root@docker-lab:~/019# docker images -a
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
www1707/test        v1.9.1              97935339c795        3 minutes ago       1.2MB
 
 
ps  删除Repository的方法如下
 
posted @ 2019-01-10 21:41  三角形  阅读(140)  评论(0编辑  收藏  举报