How do I set up a private Docker registry?
I'd like to host my own custom images on a private registry -- how might I go about that?
1 Reply
This is a great question, and its solution is easier than you might think!
In order to run a registry on a Linode, you'll first need to have Docker installed and configured. If you're unsure of how to do so, I'd recommend taking a look at our guide on Docker microservices.
That's right, Docker Registry is, in and of itself, a Docker image! To pull the container, you can run the following command:
$ docker run -d -p 5000:5000 --restart=always --name registry registry:2
You can verify that you've successfully pulled the image with this command:
$ docker ps
This will allow for your image to be run by Docker instances down the line:
$ docker tag <your-image-name> <your-registry's-IP-address>:5000/<your-image-name>
Similar to the previous step, you can verify that this worked as intended with $ docker images
.
This will look very similar to the tag
command in the previous step:
$ docker push <your-registry's-IP-address>:5000/<your-image-name>
If you happen to receive an error because your registry responded with an HTTP message as opposed to HTTPS, you can add the following to your /etc/docker/daemon.json
file:
{
"insecure-registries" : ["<your-registry's-IP-address>:5000"]
}
From here, you should be pull your image from your registry. If you happen to notice any additional issues, though, feel free to share them here.