欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

docker 构建私有仓库

程序员文章站 2024-03-12 22:38:14
...
  1. 使用官方提供的镜像启动仓库
docker run -d -p 5000:5000 --restart=always --name registry -v /home/docker/registry/:/var/lib/registry registry:2
  1. docker 1.3之后docker拉取镜像默认是https,可以修改启动项(如果直接使用ip端口则将'docker.registry'改为ip端口):
--insecure-registry  docker.registry
  1. 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;
   }
}

转载于:https://my.oschina.net/Traveller/blog/758780