Docker是基于Go语言实现的云开源项目。Docker的主要目标是**“Build,Ship and Run Any App,Anywhere”**。也就是通过对应用组件的封装、分发、部署、运行等生命周期的管理,使用户的APP(可以是一个WEB应用或数据库应用等等)及其运行环境能够做到“一次镜像,处处运行”。
下载并运行私有库
docker run -d -p 5000:5000 -v /zzyyuse/myregistry/:/tmp/registry --privileged=true registry
准备 安装了 ifconfig命令 的ubuntu镜像
从Hub上下载ubuntu镜像到本地并成功运行,原始的Ubuntu镜像是不带着ifconfig命令的
外网连通的情况下,安装ifconfig命令并测试通过
root@1c05aeae2405:/# apt-get update
...
root@1c05aeae2405:/# apt-get install net-tools
...
root@1c05aeae2405:/# ifconfig
eth0: flags=4163 mtu 1500inet 172.17.0.3 netmask 255.255.0.0 broadcast 172.17.255.255...
lo: flags=73 mtu 65536inet 127.0.0.1 netmask 255.0.0.0...
安装完成后,提交成我们自己的新镜像
docker commit -m "add config ok" -a "lzw" 1c05aeae2405 ifconfig/ubuntu:2.1
启动我们的新镜像并和原来的对比
curl 验证私服库上有什么镜像1
curl -XGET http://10.0.8.11:5000/v2/_catalog
将准备好的镜像修改符合私服规范的Tag
docker tag ifconfig/ubuntu:2.1 10.0.8.11:5000/ifconfig/ubuntu:1.2
修改配置文件使 docker 支持http
docker默认不允许http方式推送镜像,通过配置选项来取消这个限制。====> 修改完后如果不生效,建议重启docker
"insecure-registries": ["10.0.8.11:5000"]
push 推送到私服库并验证
docker push 10.0.8.11:5000/ifconfig/ubuntu:1.2
curl -XGET http://10.0.8.11:5000/v2/_catalog
docker pull 10.0.8.11:5000/ifconfig/ubuntu:1.2