这篇文章将为大家详细讲解有关docker怎样构建私有仓库,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。
使用官方提供的镜像启动仓库
docker run -d -p 5000:5000 --restart=always --name registry -v /home/docker/registry/:/var/lib/registry registry:2
docker 1.3之后docker拉取镜像默认是https,可以修改启动项(如果直接使用ip端口则将'docker.registry'改为ip端口):
--insecure-registry docker.registry
nginx 配置
server {
listen 80 default;
server_name _;
root html;
return 404;
}
server {
listen 80;
server_name docker.registry;
access_log /usr/local/nginx/logs/registry.access.log main;
error_log /usr/local/nginx/logs/registry.error.log;
location / {
# auth_basic "registry";
proxy_pass http://127.0.0.1:5000;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Authorization "";
client_body_buffer_size 128k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 8k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
}
location /v2/ {
# auth_basic "Registry realm";
# add_header 'Docker-Distribution-Api-Version' 'registry/2.0' always;
proxy_pass http://127.0.0.1:5000;
# proxy_set_header Host \$http_host; # required for docker client's sake
# proxy_set_header X-Real-IP \$remote_addr; # pass on real client's IP
# proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
# proxy_set_header X-Forwarded-Proto $scheme;
proxy_read_timeout 900;
}
}
关于“docker怎样构建私有仓库”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,使各位可以学到更多知识,如果觉得文章不错,请把它分享出去让更多的人看到。