Creating the Docker registry key

Connecting to a private Docker registry is a necessity in production environments. Since this use case is so common, Kubernetes has provided mechanisms to create the connection:

kubectl create secret docker-registry <secret-name> --docker-server=<your-registry-server> --docker-username=<your-name> --docker-password=<your-pword> --docker-email=<your-email>

The first parameter is the secret type, which is docker-registry. Then, you give the secret a name; for example, regcred. The other parameters are the Docker server (https://index.docker.io/v1/ for Docker Hub), your username, password, and email.

You can retrieve the secret in the same way as other secrets by using kubectl to access secrets.