erwewwe 发表于 2017-12-7 16:14:17

CentOS7下快速搭建Docker私有库


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



你不知道的事 发表于 2017-12-14 08:06:44

大神!赞一个!!

淡夏阳光 发表于 2018-1-27 20:44:34

这个好!
页: [1]
查看完整版本: CentOS7下快速搭建Docker私有库