您的位置:首页 > 运维架构 > Docker

CentOS7下快速搭建Docker私有库

2017-12-06 14:24 337 查看

1. 安装Docker

yum -y install docker

2. 启动Docker服务

systemctl enable docker
systemctl start docker

3. 启动Docker私有库

mkdir /home/docker_repo
cd /home/docker_repo
docker run -d -p 5000:5000 --name registry --restart=always --privileged=true -v $PWD:/var/lib/registry registry:2

4. 提交Docker镜像

docker tag docker.io/hello-world:latest 192.168.1.75:5000/hello-world:latest
docker push 192.168.1.75:5000/hello-world

如果push遇到问题,编辑/usr/lib/systemd/system/docker.service,在ExecStart=之后追加一行参数:

--insecure-registry=192.168.1.75:5000 \

然后重启Docker服务:

systemctl daemon-reload
systemctl restart docker

5. Docker私有库HTTP API

测试库内已有centos和Docker官方的hello-world镜像

查看当前库列表
http://192.168.1.75:5000/v2/_catalog

返回:

{
"repositories": [
"centos",
"hello-world"
]
}


查看某个库标签列表
http://192.168.1.75:5000/v2/hello-world/tags/list

返回:

{
"name": "hello-world",
"tags": [
"latest"
]
}

注: 需要把192.168.1.75替换成你的Docker私有库所在服务器IP

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  docker 容器 linux