其他分享
首页 > 其他分享> > 上传、下载镜像:dockerhub和gitlab

上传、下载镜像:dockerhub和gitlab

作者:互联网

 

 

打标签注意,tag默认是latest。若不是,则需要标明tag。


 

DockerHub上传和下载docker镜像

 

1.先申请一个自己的DockerHub账户。

2.dckerhub上传下载镜像

①.登录 docker login -u  dockerhub账号ID  (docker login 默认登录的dockerhub)

 

 

②.给镜像打标签,标签规则(github_ID/仓库名:tagname)

[root@localhost gaokai]# docker images
REPOSITORY     TAG         IMAGE ID             CREATED        SIZE
redis         alpine      3900abf41552         3 weeks ago     32.4MB
python       3.7-alpine   a1034fd13493         3 weeks ago     41.8MB
centos        latest      5d0da3dc9764         3 months ago    231MB     

#docker tag REPOSITORY:TAG github账号/仓库名:标签(TAG)
#docker tag centos 3240421650/test:centos01

结果(标题对应如上)
REPOSITORY         TAG       IMAGE ID             CREATED        SIZE

3240421650/test centos01 5d0da3dc9764 3 months ago 231MB

 

③.推送镜像

#docker push REPOSITORY:TAG (REPOSITORY要是"账号/仓库名")
#docker push 3240421650/test:centos01

如图

 

 然后登录dockerhub查看

 

 

DockerHub参考文章链接:https://cloud.tencent.com/developer/article/1549825

 


 

Gitlab上传、下载docker镜像

 

gitlab上传下载镜像
1.登录

gitlab和dockerhub不同,它需要指定gitlab的使用用户、和对应的ip地址及仓库开通的端口
 
#docker login -u root 192.168.24.136:4567 (gitlab需要指定地址和端口)

 

2.给镜像打标签,标签规则(镜像仓库地址/仓库名/tagname)

#docker tag REPOSITORY:TAG 镜像仓库地址/用户名/仓库名/tagname

如:
# docker tag centos:laster 192.168.24.136:4567/root/ceshi/centos01

如下:

[root@localhost ~]# docker images
REPOSITORY                      TAG        IMAGE ID        CREATED      SIZE
redis                        alpine      3900abf41552      3 weeks ago    32.4MB
python                       3.7-alpine    a1034fd13493      3 weeks ago    41.8MB
centos                         latest      5d0da3dc9764      3 months ago   231MB
192.168.24.136:4567/root/ceshi/centos01    latest      5d0da3dc9764     3 months ago   231MB

 

3.gitlab上传镜像:

#docker push  192.168.24.136:4567/root/ceshi/centos01:latest

 

4.gitlab下载镜像

    #docker pull 192.168.24.136:4567/root/ceshi/centos01
    注意:如果写出"# docker tag python:3.7-alpine 192.168.24.136:4567/root/ceshi:python01",
        则会成这种结果
        192.168.24.136:4567/root/ceshi        python01       a1034fd13493   3 weeks ago      41.8MB
    同时,上传gitlab后,名称为root/ceshi/根镜像
    
使用不同的镜像名称
GitLab 最多支持3个级别的镜像命名。以下镜像名称示例对当前项目有效:

192.168.24.134:4567/muyu/ceshi:tag
192.168.24.134:4567/muyu/ceshi/optional-image-name:tag
192.168.24.134:4567/muyu/ceshi/optional-name/optional-image-name:tag

 

标签:ceshi,dockerhub,gitlab,tag,4567,镜像,docker,root
来源: https://www.cnblogs.com/gk888/p/15747930.html