Docker Registry

Docker registry is a centralized storage which holds docker images. It is the best way to share docker images for services or developers.

Deploy Docker Registry On A Linux Server

Docker registry is typically deployed on a linux server. Docker register can be deployed as a docker container. In order to do so, take the following steps:

  1. Install docker on your linux server (follow this link).
  2. Run the following command
docker run -d -p 5000:5000 --restart=always --name registry registry:2

After running this command, you docker registry’s endpoint is {YOUR_SERVER_IP_ADDR}:5000. For example, if you server’s IP address is 192.168.1.100, your docker registry endpoint is 192.168.1.100:5000.

Client Side Configuration

By default, the above docker registry deployment does not come with a SSL certification, which is considered as an insecure registry. To use insecure docker registry, you’ll need to have the following config in your /etc/docker/daemon.json file.

{
    "insecure-registries" : ["{YOUR_DOCKER_REGISTRY_SERVER_ENDPOINT}"]
}

Here, YOUR_DOCKER_REGISTRY_SERVER_ENDPOINT needs to be your docker registry endpoint, for example, 192.168.1.100:5000.

Use Docker Registry

To use docker registry, you have to make sure that your docker image is named in this form, {YOUR_DOCKER_REGISTRY_SERVER_ENDPOINT}/{IMAGE_NAME}:{IMAGE_TAG}.

  • {YOUR_DOCKER_REGISTRY_SERVER_ENDPOINT}/{IMAGE_NAME} is your docker image repo,
  • {IMAGE_NAME} can be anything, for example, my-docker-image.
  • {IMAGE_TAG} can be anything, for example, v1. You can also leave it empty. If it is empty, you docker image name is {YOUR_DOCKER_REGISTRY_SERVER_ENDPOINT}/{IMAGE_NAME}.

For example, a legit docker image name can be 192.168.1.100:5000/my-docker-image:v1.

Push Image To Docker Registry

To push your docker image to the docker registry, use this command:

docker push 192.168.1.100:5000/my-docker-image:v1

Pull Image From Docker Registry

To pull your docker image from the docker registry, use this command:

docker pull 192.168.1.100:5000/my-docker-image:v1