Setting up a local docker image repository

A Docker registry server is also a docker container: which means that you should first download the image of the registry server from the global docker image server, and run it as a container.


$> sudo docker pull registry:latest

$> sudo docker run -d -p 5000:5000 --name local-registry -v /tmp/registry:/tmp/registry registry

After that, you can actually upload your docker image to the local registry by (1) creating a tag for the image, and (2) register the image to the local registry server.


$> docker tag ubuntu-git-nginx:0.2 localhost:5000/ubuntu-git-nginx:0.2

$> docker push localhost:5000/ubuntu-git-nginx:0.2

Note that you push your image by the tag you have just given, not by the name of the image.

2 thoughts on “Setting up a local docker image repository

  1. One missing piece: As I omit the command name to start the registry server, the container will be stopped immediately. (Thus, ‘sudo docker ps’ will show nothing about the local-registry container) So, you should start the container manually by ‘sudo docker start local-registry’ .

    Like

  2. following is the syntax of the docker tag command.
    docker tag [OPTIONS] IMAGE[:TAG] [REGISTRYHOST/][USERNAME/]NAME[:TAG]
    Thus, when you tag, you give a tag to an image, and ‘NAME’ is the name of the image. Further, when you give a tag, you can specify the registry host with the tag, which is where the tagged image would be pushed.
    When you push, you give NAME[:TAG] to the command. Optionally, you can prefix the REGISTRYHOST.

    Like

Leave a comment