Deploy a Docker Trusted Registry (DTR) server, where you can storing and distributing docker images on your local network.
Deploy a Docker Trusted Registry (DTR) server, where you can storing and distributing docker images on your local network.
Docker Trusted Registry (DTR) requests the certificate file as .crt and .key. My certificate is .pfx file. First, using OpenSSL, I extract .key and .crt from my certificate with .pfx extension. (Certificate extraction was done on Windows 10 operating system.)
First, we extract the encrypted .key file.
openssl pkcs12 -in CERTIFICATE_FILE.pfx -nocerts -out keyfile-encrypted.key
To unencrypt the key, do:
openssl rsa -in keyfile-encrypted.key -out keyfile.key
openssl pkcs12 -in CERTIFICATE_FILE.pfx -clcerts -nokeys -out certfile.crt
root/certs
directory and copy the .crt and .key files into the directory.root/registry
directory and copy the registry/config.yml
files into the directory.We configure our DTR server to accept CORS for Docker Registry UI.
Access-Control-Allow-Origin: ['*']
Access-Control-Allow-Methods: ['HEAD', 'GET', 'OPTIONS', 'DELETE']
Access-Control-Expose-Headers: ['Docker-Content-Digest']
root/auth
.
docker run \
--entrypoint htpasswd \
registry:2 -Bbn testuser testpassword > auth/htpasswd
docker run -d \
--restart=always \
--name registry \
-v "$(pwd)"/certs:/certs \
-v "$(pwd)"/auth:/auth \
-v "$(pwd)"/registry/config.yml:/etc/docker/registry/config.yml \
-v "$(pwd)"/registry/lib:/var/lib/registry \
-e REGISTRY_HTTP_ADDR=0.0.0.0:443 \
-e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/certfile.crt \
-e REGISTRY_HTTP_TLS_KEY=/certs/keyfile.key \
-p 443:443 \
registry:2
docker login myregistrydomain.com
After completing the installation, you may get an error as follows during docker pull and push operations; Error response from daemon: Get https://registry.yourdomain.com/v2/: x509: certificate signed by unknown authority
To fix this problem;
/etc/docker/certs.d
directory.This example should be like this;/etc/docker/certs.d/registry.yourdomain.com/certfile.crt
We use Docker Registry UI to manage our images on our DTR server through a user interface.
docker run -d \
--restart=always \
--name registry-ui \
-p 80:80 \
-e URL=https://registry.yourdomain.com \
-e DELETE_IMAGES=true \
joxit/docker-registry-ui:static