-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCentOS 7 Install Docker Registry.txt
71 lines (56 loc) · 2.23 KB
/
CentOS 7 Install Docker Registry.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
docker run -d --name registry \
-v $YOUR_REGISTRY_DIR:/registry \
-e "SETTINGS_FLAVOR=local" \
-e "STORAGE_PATH=/registry" \
registry
# Run registry
docker run -td --restart=always --name registry.ucoder.ir -e "SETTINGS_FLAVOR=local" -p 5000:5000 registry
# create Nginx configuration file
sudo vim /etc/nginx/conf.d/registry.ucoder.ir.conf
...............................
server {
listen 80;
server_name registry.ucoder.ir;
access_log /var/log/nginx/access_registry.log;
error_log /var/log/nginx/error_registry.log;
client_max_body_size 0; # disable any limits to avoid HTTP 413 for large image uploads
# required to avoid HTTP 411: see Issue #1486 (https://github.com/dotcloud/docker/issues/1486)
chunked_transfer_encoding on;
# set HSTS-Header because we only allow https traffic
add_header Strict-Transport-Security "max-age=31536000;";
add_header 'Docker-Distribution-Api-Version' 'registry/2.0' always;
location / {
if ($http_user_agent ~ "^(docker\/1\.(3|4|5(?!\.[0-9]-dev))|Go ).*\$" ) {
return 404;
}
proxy_pass http://127.0.0.1:5000/;
proxy_ssl_verify off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 900;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
}
}
..............................
# allow nginx to connect to registry
sudo semanage port -a -t http_port_t -p tcp 5000
sudo /usr/sbin/setsebool -P httpd_can_network_connect 1
# install certbox (lets encrypt)
...............................
yum -y install yum-utils
yum-config-manager --enable rhui-REGION-rhel-server-extras rhui-REGION-rhel-server-optional
sudo yum install certbot-nginx
...............................
# Enable CertBot on our Nginx Configuration
...............................
sudo certbot --nginx
...............................
## OR IF YOU RUN INTO BUG PROBLEM
...............................
sudo certbot --authenticator standalone --installer nginx --pre-hook "systemctl stop nginx" --post-hook "systemctl stop nginx"
...............................