docker_practice/repository/nexus3_registry.md

105 lines
4.4 KiB
Go
Raw Normal View History

# Nexus3.x
2018-05-31 18:30:41 +08:00
使 Docker Registry Registry Nexus `Nexus3.x` Docker 使 [`Nexus3.x`](https://www.sonatype.com/nexus/repository-oss/download) 一个软件来管理 `Docker` , `Maven` , `Yum` , `PyPI` 等是一个明智的选择。
2018-05-31 18:30:41 +08:00
## Nexus
2018-05-31 18:30:41 +08:00
```bash
$ docker run -d --name nexus3 --restart=always \
-p 8081:8081 \
--mount src=nexus-data,target=/nexus-data \
sonatype/nexus3
```
3-5 `nexus3` 退使 `http://YourIP:8081` 访 Nexus
Nexus `admin` `admin123` 齿
##
2018-05-31 18:30:41 +08:00
`Repository->Repositories` `Create repository` `docker (hosted)`
* Name:
* HTTP: 访
* Enable Docker V1 API: V1
* Hosted -> Deployment pollcy: Allow redeploy Docker
docker (proxy) DockerHub docker (group) hosted proxy 访 DockerHub Nexus
## 访
2018-05-31 18:30:41 +08:00
`Security->Realms` Docker Bearer Token Realm
`Security->Roles`->`Create role` `Privlleges` docker
`Security->Users`->`Create local user` `Roles`
## NGINX
2018-05-31 18:30:41 +08:00
[`私有仓库高级配置`](registry_auth.md)
NGINX
```nginx
upstream register
{
server "YourHostName OR IP":5001; # HTTP
check interval=3000 rise=2 fall=10 timeout=1000 type=http;
check_http_send "HEAD / HTTP/1.0\r\n\r\n";
check_http_expect_alive http_4xx;
}
server {
server_name YourDomainName;# DNS 使 IP 访
listen 443 ssl;
2018-05-31 18:30:41 +08:00
ssl_certificate key/example.crt;
ssl_certificate_key key/example.key;
2018-05-31 18:30:41 +08:00
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
large_client_header_buffers 4 32k;
client_max_body_size 300m;
client_body_buffer_size 512k;
proxy_connect_timeout 600;
proxy_read_timeout 600;
proxy_send_timeout 600;
proxy_buffer_size 128k;
proxy_buffers 4 64k;
proxy_busy_buffers_size 128k;
proxy_temp_file_write_size 512k;
location / {
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://register;
proxy_read_timeout 900s;
}
error_page 500 502 503 504 /50x.html;
}
```
## Docker 访
2018-05-31 18:30:41 +08:00
SSL Docker Docker
使 SSL 访访
```bash
$ openssl s_client -showcerts -connect YourDomainName OR HostIP:443 </dev/null 2>/dev/null|openssl x509 -outform PEM >ca.crt
$ cat ca.crt | sudo tee -a /etc/ssl/certs/ca-certificates.crt
$ systemctl restart docker
```
使 `docker login YourDomainName OR HostIP` Nexus