Created
September 22, 2015 20:36
-
-
Save rlister/51c58bc249eea7e23c71 to your computer and use it in GitHub Desktop.
Running docker registry on fleet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
user nginx; | |
worker_processes 4; | |
error_log /var/log/nginx/error.log warn; | |
pid /var/run/nginx.pid; | |
events { | |
worker_connections 1024; | |
} | |
http { | |
include /etc/nginx/mime.types; | |
default_type application/octet-stream; | |
log_format main '$remote_addr - $remote_user [$time_local] "$request" ' | |
'$status $body_bytes_sent "$http_referer" ' | |
'"$http_user_agent" "$http_x_forwarded_for"'; | |
access_log /var/log/nginx/access.log main; | |
sendfile on; | |
keepalive_timeout 65; | |
upstream registry { | |
server 172.17.42.1:5000; | |
} | |
server { | |
listen 80; | |
client_max_body_size 0; # avoid HTTP 413 for large image uploads | |
chunked_transfer_encoding on; # avoid HTTP 411 | |
location /v2/ { | |
## deny docker pre-1.6.0: did not properly set the user agent on ping, catch "Go *" user agents | |
if ($http_user_agent ~ "^(docker\/1\.(3|4|5(?!\.[0-9]-dev))|Go ).*\$") { | |
return 404; | |
} | |
auth_basic "Restricted"; | |
auth_basic_user_file /etc/htpasswd; | |
add_header "Docker-Distribution-Api-Version" "registry/2.0" always; | |
proxy_pass http://registry; | |
proxy_set_header Host $http_host; # required for docker client | |
proxy_set_header X-Real-IP $remote_addr; # pass on real client IP | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header X-Forwarded-Proto "https"; | |
proxy_read_timeout 900; | |
} | |
} | |
} | |
daemon off; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=Docker registry nginx proxy | |
Require=docker.service | |
After=docker.service | |
[Service] | |
TimeoutStartSec=0 | |
ExecStartPre=-/usr/bin/docker rm nginx | |
ExecStartPre=usr/bin/docker pull rlister/nginx:stable | |
ExecStart=/usr/bin/docker run --name nginx \ | |
-v /etc/htpasswd:/etc/htpasswd \ | |
-v /etc/nginx.conf:/etc/nginx/nginx.conf \ | |
-p 80:80 \ | |
rlister/nginx:stable | |
ExecStop=/usr/bin/docker stop nginx | |
Restart=on-failure | |
RestartSec=60 | |
[X-Fleet] | |
MachineMetadata=role=index | |
Global=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=Docker registry | |
Require=docker.service | |
After=docker.service | |
[Service] | |
TimeoutStartSec=0 | |
Environment=REGISTRY_VERSION=2.0.1 | |
ExecStartPre=-/usr/bin/docker rm registry | |
ExecStartPre=/usr/bin/docker pull registry:${REGISTRY_VERSION} | |
ExecStart=/usr/bin/docker run --name registry \ | |
-p 5000:5000 \ | |
-e REGISTRY_STORAGE=s3 \ | |
-e REGISTRY_STORAGE_S3_REGION=us-east-1 \ | |
-e REGISTRY_STORAGE_S3_BUCKET=xxx \ | |
registry:${REGISTRY_VERSION} | |
ExecStop=/usr/bin/docker stop registry | |
Restart=on-failure | |
RestartSec=60 | |
[X-Fleet] | |
MachineMetadata=role=index | |
Global=true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment