本地镜像发布流程
docker镜像生成
docker commit 提交一个镜像(看上一节 )
dockerFile 构建新的镜像(后续更新 )
阿里云公有云仓库 docker镜像推送到阿里云
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 [root@CentOs7_001 ubuntu] REPOSITORY TAG IMAGE ID CREATED SIZE igsshan/ubuntu 0.0.2 2a0da7b9e07a 41 minutes ago 184MB igsshan/ubuntu 0.0.1 df481e243482 7 hours ago 72.8MB ubuntu latest ba6acccedd29 19 months ago 72.8MB 01.登录阿里云平台(https://www.aliyun.com) ---> 02.选择<控制台> ---> 03.选择<镜像容器服务> ---> 04.点击<实例列表> ---> 05.点击<个人实例> ---> 06.点击<仓库管理-命名空间> ---> 07.创建新的命名空间<最好选择公开> ---> 08.点击<镜像仓库> ---> 09.创建新的镜像仓库挂载在刚刚新建的命名空间下<最好选择公开> ---> 10.完成 [root@CentOs7_001 ubuntu] 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/ Login Succeeded [root@CentOs7_001 ubuntu] [root@CentOs7_001 ubuntu] REPOSITORY TAG IMAGE ID CREATED SIZE igsshan/ubuntu 0.0.2 2a0da7b9e07a 54 minutes ago 184MB registry.cn-hangzhou.aliyuncs.com/igsshansz/iubuntu 0.0.2 2a0da7b9e07a 54 minutes ago 184MB igsshan/ubuntu 0.0.1 df481e243482 7 hours ago 72.8MB ubuntu latest ba6acccedd29 19 months ago 72.8MB [root@CentOs7_001 ubuntu] The push refers to repository [registry.cn-hangzhou.aliyuncs.com/igsshansz/iubuntu] 6b6477d03f57: Pushed 9f54eef41275: Pushed 0.0.2: digest: sha256:4761058acfbdebfc82344482062035188e3cd904740e546a6be96f5181957b95 size: 741 [root@CentOs7_001 ubuntu]
docker镜像拉取到本地
使用脚本命令快捷拉取到本地
1 2 3 4 5 docker pull registry.cn-hangzhou.aliyuncs.com/igsshansz/iubuntu:[镜像版本号] docker pull registry.cn-hangzhou.aliyuncs.com/igsshansz/iubuntu:0.0.2
dockerRegistry私有云仓库
官方Docker Hub地址:https://hub.docker.com/,中国大陆访问太慢了且准备被阿里云取代的趋势,不太主流。
Dockerhub、阿里云这样的公共镜像仓库可能不太方便,涉及机密的公司不可能提供镜像给公网,所以需要创建一个本地私人仓库供给团队使用,基于公司内部项目构建镜像。
Docker Registry是官方提供的工具,可以用于构建私有镜像仓库
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 [root@CentOs7_001 ubuntu] REPOSITORY TAG IMAGE ID CREATED SIZE igsshan/ubuntu 0.0.2 2a0da7b9e07a 41 minutes ago 184MB igsshan/ubuntu 0.0.1 df481e243482 7 hours ago 72.8MB ubuntu latest ba6acccedd29 19 months ago 72.8MB docker pull registry docker run -d -p 5000:5000 --name="registry" -v /mydata/docker/registry.:/tmp/registry --privileged=true registry -d : 后台启动 -p : 端口映射 -v : 容器卷挂载到本地 [root@CentOs7_001 registry] ec2ec8e4ef07cbe0af3ce3d81b517790ec04091c2ec6d9b7c1f154bc5a7f7427 [root@CentOs7_001 registry] CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES ec2ec8e4ef07 registry "/entrypoint.sh /etc…" 5 seconds ago Up 3 seconds 0.0.0.0:5000->5000/tcp, :::5000->5000/tcp registry curl -X GET http://192.168.33.101:5000/v2/_catalog [root@CentOs7_001 registry] {"repositories" :[]} [root@CentOs7_001 registry] { "registry-mirrors" : ["https://lljn1hsm.mirror.aliyuncs.com" ] } [root@CentOs7_001 registry] { "registry-mirrors" : ["https://lljn1hsm.mirror.aliyuncs.com" ], "insecure-registries" : ["192.168.33.101:5000" ] } docker run -it nbuntu /bin/bash root@5e28e2566dfe:/ bash: ipconfig: command not found apt-get update apt-get install -y net-tools root@5e28e2566dfe:/ eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 172.17.0.3 netmask 255.255.0.0 broadcast 172.17.255.255 ether 02:42:ac:11:00:03 txqueuelen 0 (Ethernet) RX packets 4396 bytes 27015468 (27.0 MB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 2826 bytes 157654 (157.6 KB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 [root@CentOs7_001 registry] CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 5e28e2566dfe ubuntu "/bin/bash" 2 minutes ago Up 2 minutes gifted_varahamihira ec2ec8e4ef07 registry "/entrypoint.sh /etc…" 4 minutes ago Up 4 minutes 0.0.0.0:5000->5000/tcp, :::5000->5000/tcp registry [root@CentOs7_001 registry] sha256:b5f53944390b484b1d0ac66344329873b870b18c7194b9df3423fceb44781625 [root@CentOs7_001 registry] [root@CentOs7_001 registry] REPOSITORY TAG IMAGE ID CREATED SIZE 192.168.33.101:5000/ubuntu 0.0.3 b5f53944390b About a minute ago 117MB igsshan/ubuntu 0.0.3 b5f53944390b About a minute ago 117MB [root@CentOs7_001 registry] The push refers to repository [192.168.33.101:5000/ubuntu] 149dc2112ad9: Pushed 9f54eef41275: Pushed 0.0.3: digest: sha256:e880d5223e052ede7b5dbd6d76b364188d87080321275d7a9e7bf61a820340b2 size: 741 [root@CentOs7_001 registry] {"repositories" :["ubuntu" ]} [root@CentOs7_001 registry] 0.0.3: Pulling from ubuntu 7b1a6ab2e44d: Already exists f746d0431684: Pull complete Digest: sha256:e880d5223e052ede7b5dbd6d76b364188d87080321275d7a9e7bf61a820340b2 Status: Downloaded newer image for 192.168.33.101:5000/ubuntu:0.0.3 192.168.33.101:5000/ubuntu:0.0.3 [root@CentOs7_001 registry] REPOSITORY TAG IMAGE ID CREATED SIZE 192.168.33.101:5000/ubuntu 0.0.3 b5f53944390b 19 minutes ago 117MB [root@CentOs7_001 registry] root@26a58e5a4fff:/ root@26a58e5a4fff:/ eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 172.17.0.4 netmask 255.255.0.0 broadcast 172.17.255.255 ether 02:42:ac:11:00:04 txqueuelen 0 (Ethernet) RX packets 8 bytes 656 (656.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
如果不修改配置文件,默认不支持http的,推送镜像到私服报错<Error response from daemon: Get “https://192.168.33.101:5000/v2/ “: http: server gave HTTP response to HTTPS client>