目录
一、制作一个简单的Ubuntu中安装vim的镜像
二、在阿里云上面创建镜像仓库
三、从阿里云仓库中上传和拉取镜像
一、制作一个简单的Ubuntu中安装vim的镜像
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
二、在阿里云上面创建镜像仓库
三、从阿里云仓库中上传和拉取镜像
直接复制示例中的代码
# 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 #查看信息是否还在