安装docker
yum install docker
启动docker
systemctl start docker
拉取registry镜像
docker pull registry
创建仓库配置文件/etc/docker/registry/config.yml,文件内容如下:
version: 0.1log: fields: service: registrystorage: delete: enabled: true cache: blobdescriptor: inmemory filesystem: rootdirectory: /var/lib/registryhttp: addr: :5000 headers: X-Content-Type-Options: [nosniff]health: storagedriver: enabled: true interval: 10s threshold: 3
启动registry
docker run -d --name registry -p 5000:5000 -v /var/lib/registry:/var/lib/registry -v /etc/docker/registry/config.yml:/etc/docker/registry/config.yml registry
执行docker pull或者docker push的时候可能会提示以下错误:
server gave HTTP response to HTTPS client原因是客户端采用https,而docker registry未采用https服务所致解决方法:
修改docker客户端的systemd文件centos系统:/usr/lib/systemd/system/docker.serviceubuntu系统:/lib/systemd/system/docker.service
找到ExecStart这行,增加这段内容:
--insecure-registry 1.2.3.4:5000
其中,1.2.3.4是docker仓库地址
重启启动docker服务
systemctl daemon-reloadsystemctl restart docker