mac上搭建docker镜像私服
1、创建私服容器
docker run -d -e SETTINGS_FLAVOR=dev -e STORAGE_PATH=/tmp/registry -v /opt/data/registry:/tmp/registry -p 5000:5000 registry
2、修改配置文件/var/lib/boot2docker/profile
如果不修改这个配置文件,上传镜像时会出现如下错误
Error: v1 ping attempt failed with error: Get https://192.168.99.100:5000/v1/_ping: dial tcp 192.168.99.100:5000: connection refused. If this private registry supports only HTTP or HTTPS with an unknown CA certificate, please add `--insecure-registry 192.168.99.100:5000` to the daemon's arguments. In the case of HTTPS, if you have access to the registry's CA certificate, no need for the flag; simply place the CA certificate at /etc/docker/certs.d/192.168.99.100:5000/ca.crt
ssh连接default这个docker host
docker-machine ssh default
编辑/var/lib/boot2docker/profile文件,编辑之后如下
EXTRA_ARGS=' --label provider=virtualbox ' CACERT=/var/lib/boot2docker/ca.pem DOCKER_HOST='-H tcp://0.0.0.0:2376' DOCKER_STORAGE=aufs DOCKER_TLS=auto SERVERKEY=/var/lib/boot2docker/server-key.pem SERVERCERT=/var/lib/boot2docker/server.pem #添加的是下面这句 EXTRA_ARGS="--insecure-registry 192.168.99.100:5000"
3、重启docker host
docker-machine restart default
4、查看私服上所有的镜像
curl -X GET http://192.168.99.100:5000/v1/search
5、从官方下载镜像
docker pull hello-world
6、给镜像加上标签
如果不加标签,上传镜像时会提示没有hello-world这个库
docker tag hello-world 192.168.1.230:5000/hello-world
7、上传到私服
docker push 192.168.1.230:5000/hello-world
8、从私服上下载镜像
docker pull 192.168.1.230:5000/hello-world
9、删除私服上的镜像
目前还没有办法删除镜像