Docker Insecure Registry

Insecure registry Pushing from Docker. Let’s assume the private insecure registry is at 10.141.241.175 on port 32000. The images we build need to be tagged with the. Configuring Docker to Push or Pull from an Insecure Registry. The Docker runtime establishes trust of a remote image registry based on the validity of its Transport Layer Security (TLS) certificate. If your cluster uses a self-signed certificate, Docker will consider it “insecure” by default. In order to docker login to a private registry you have to distribute the certificate generated above to the Docker-nodes. Download.example.com wildcard cert and the intermediate cert for self-signed certs from haxx.se and restart the Docker daemon. Deploy a registry server. Estimated reading time: 18 minutes. This page contains information about hosting your own registry using the open source Docker Registry. For information about Docker Hub, which offers a hosted registry with additional features such as teams, organizations, web hooks, automated builds, etc, see Docker Hub. Let me elaborate. If some additional registry requires user to login, the credentials won't get to docker daemon unless the target registry is fully-qualified. For example using (-add-registry my.private.registry.cz - requiring user to authenticate): docker login my.private.registry.cz docker pull miminar/rhel7.

If you are creating custom docker images for your enterprise, you have two choices on where to host your docker images:

  1. Docker Hub – This hosted registry service is free and provided by Docker Inc. They also have several enterprise level features where you can create multiple accounts for your organizations, setup automatic builds, etc.
  2. Self Hosted Docker Registry – You can setup docker registry within your organization that will host your own docker images.

This tutorial explains how to setup a a secure self-hosted docker registry.

1. Setup TLS Certificate and Key

Copy your existing crt and key file to ~/docker-certs directory

In this example, I’m using thegeekstuff.crt certificate file, and thegeekstuff.key file that was generated for my Apache webserver.

For details on how to create your own certificate and key file, refer to this: How To Generate SSL Key, CSR and Self Signed Certificate

2. Manage Intermediate Certificate file

In this case, I also had an Intermediate Certificate from my certificate authority.

Insecure

For docker registry, you should combine both the certificate and the intermediate certificate into the same certificate file.

i.e Append the content of your intermediate certificate bundle to your certificate file as shown below.

3. Start Your Secure Docker Registry

Now, start your secure docker registry as shown below.

In the above command:

  • Docker registry is getting started on port 5000
  • The name of this docker container is “registry”
  • The local directory which contains the certificate /root/docker-certs is mapped as /certs inside the docker registry container
  • REGISTRY_HTTP_TLS_CERTIFICATE variable points to the certificate filename with full path
  • REGISTRY_HTTP_TLS_KEY variable points to the key filename with full path

Once you start the docker registry, you’ll now see the registry container running as shown below:

Docker Insecure Registry Ubuntu 20.04

4. Access your Secure Docker Registry

Docker insecure registry centos

Once the secure docker registry is setup, you can access it from other servers inside your network (or from outside your network), and use all the standard docker commands on it.

Docker Insecure Registry Not Working

For example, you can push or pull an image to this secure docker registry as shown below.

5. Setup InSecure Docker Registry

Note: If you are having any trouble with the Secure Docker Registry, for debugging purpose, start your registry without the certificate and see how it works as shown below:

When you try to pull an image (or perform any other operation) from your docker registry, you might get the following “oversized record received with length” error message.

For example, when I executed the following command on a remote server (not on the server where the docker registry is setup), I get the following error message:

In this case, 192.168.101.1 is the server where the in-secure docker registry is running (i.e without the security certificates).

In this case, on the remote server, you should allow insecure registry operations. For this, you have to pass “–insecure-registry” parameter to the DOCKER_OPTS environment variable.

Docker Insecure Registry Command

On the remote server, modify this file and add the following line:

Now, restart the docker on the remote server.

Docker Insecure Registry Settings

Now, the docker pull (or any other docker command) will work without any issues, as the insecure registry option is setup.