Last active
April 3, 2025 19:23
-
-
Save welshstew/736bb4f9e6cd7e0ef9bae4411ad2a1df to your computer and use it in GitHub Desktop.
Creating a docker registry with authentication on qnap container station
This file contains hidden or 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
htpasswd -bc docker-registry.htpasswd admin admin | |
scp docker-registry.htpasswd admin@${NAS_IP}:/share/CACHEDEV1_DATA/Container/container-station-data/application/registry/nginx/ |
This file contains hidden or 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@host ~]$ curl -k https://${NAS_IP}:6088/v2/_catalog | |
<html> | |
<head><title>401 Authorization Required</title></head> | |
<body bgcolor="white"> | |
<center><h1>401 Authorization Required</h1></center> | |
<hr><center>nginx/1.13.12</center> | |
</body> | |
</html> |
This file contains hidden or 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@host ~]$ curl -k -u admin:admin https://${NAS_IP}:6088/v2/_catalog | |
{"repositories":["admin/busybox"]} |
This file contains hidden or 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@host ~]$ curl -k https://${NAS_IP}:6088/v2/_catalog | |
{"repositories":["admin/busybox"]} |
This file contains hidden or 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
networks: {} | |
services: | |
app: | |
environment: | |
REGISTRY_HTTP_SECRET: qnap-sw2-registry | |
REGISTRY_REDIS_ADDR: cache:6379 | |
REGISTRY_STORAGE_CACHE_BLOBDESCRIPTOR: redis | |
REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY: /data/registry | |
image: registry:2.6.2 | |
volumes: | |
- registry-data:/data/registry | |
cache: | |
image: redis:4.0 | |
web: | |
image: nginx:1.13 | |
ports: | |
- 6088:5000 | |
volumes: | |
- ./nginx:/etc/nginx | |
- /etc/docker/tls/server-cert.pem:/etc/ssl/certs/docker-registry | |
- /etc/docker/tls/server-key.pem:/etc/ssl/private/docker-registry | |
version: '2' | |
volumes: | |
registry-data: null |
This file contains hidden or 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
upstream docker-registry { | |
server app:5000; | |
} | |
server { | |
listen 5000; | |
server_name localhost; | |
ssl on; | |
ssl_certificate /etc/ssl/certs/docker-registry; | |
ssl_certificate_key /etc/ssl/private/docker-registry; | |
# disable any limits to avoid HTTP 413 for large image uploads | |
client_max_body_size 0; | |
# required to avoid HTTP 411: see Issue #1486 (https://github.com/docker/docker/issues/1486) | |
chunked_transfer_encoding on; | |
location / { | |
# auth_basic "Docker Registry"; | |
# auth_basic_user_file docker-registry.htpasswd; | |
include docker-registry.conf; | |
} | |
location /v1/_ping { | |
auth_basic off; | |
include docker-registry.conf; | |
} | |
location /v1/users { | |
auth_basic off; | |
include docker-registry.conf; | |
} | |
} |
This file contains hidden or 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
Usage | |
On QTS Container Station: | |
Create application registry by [Create Container] → [Create Registry]. | |
Add Registry to searching list by [Preferences] → [Registry] → [Add] that URL is https://NAS_IP:6088 and check Trust SSL. | |
Others: | |
Add certificate to your Docker trusty list: | |
$ mkdir -p /etc/docker/certs.d/NAS_IP:6088 | |
$ scp admin@NAS_IP:/etc/docker/tls/ca.pem /etc/docker/certs.d/NAS_IP:6088/ca.crt | |
Push an image to the Registry: | |
$ docker pull busybox:latest | |
$ docker tag busybox NAS_IP:6088/username/busybox | |
$ docker push NAS_IP:6088/username/busybox |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment