7、push推送到私服库
8、再次curl验证私服库有什么镜像
9、pull到本地并运行
一、上次到阿里云服务器
1、制作一个带有vim功能的Ubuntu镜像
docker pull ubuntu
docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu latest ba6acccedd29 2 years ago 72.8MB
docker run -it ubuntu
root@8b9f2522faa0:/# apt-get update #先更新一下软件包列表
root@8b9f2522faa0:/# apt-get install vim -y
root@8b9f2522faa0:/# echo "hello world" > abc.tec #随便添加一点信息
root@8b9f2522faa0:/# cat abc.tec
hello world
按下Ctrl+p+q退出容器,容器不停止(如果直接使用exit,容器会停止运行,这样就不能制作镜像了)
# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8b9f2522faa0 ubuntu "bash" 5 minutes ago Up 5 minutes optimistic_wescoff
# docker commit -m="ubuntu add vim" -a="haha" 8b9f2522faa0 ubuntuvim:3.23
sha256:761b629328e8fb5ae1cd187d5a1b0c5f12107bcad6663b1cf8b89c93e5f5201a
# docker images #查看制作好的镜像
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntuvim 3.23 761b629328e8 56 seconds ago 191MB
2、在阿里云上面创建镜像仓库
3、从阿里云仓库中上传和拉取镜像
直接复制示例中的代码
# docker login --username=aliyun8035446320 registry.cn-hangzhou.aliyuncs.com
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/#credentials-store
Login Succeeded
# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntuvim 3.23 761b629328e8 11 minutes ago 191MB
# docker tag 761b629328e8 registry.cn-hangzhou.aliyuncs.com/yoyo_chengdu/ubuntu:3.23
# docker push registry.cn-hangzhou.aliyuncs.com/yoyo_chengdu/ubuntu:3.23
The push refers to repository [registry.cn-hangzhou.aliyuncs.com/yoyo_chengdu/ubuntu]
af91d09903b5: Pushed
9f54eef41275: Pushed
3.23: digest: sha256:f74cfb2e5ef2ad30cd14fb5da6dbbc6eae9870c4e973f181abff11cfc603f1de size: 741
# docker rmi -f 761b629328e8 #删除制作的镜像
# docker pull registry.cn-hangzhou.aliyuncs.com/yoyo_chengdu/ubuntu:3.23 #拉取镜像
# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
registry.cn-hangzhou.aliyuncs.com/yoyo_chengdu/ubuntu 3.23 761b629328e8 16 minutes ago 191MB
# docker run -it 761b629328e8
root@2fb3a6485a7f:/# cat abc.tec
hello world #查看信息是否还在
二、上传镜像到本地私有库registry
1、下载镜像docker registry
# docker pull registry