The Docker Engine needs to be explicitly setup to use HTTP for the insecure registry.
$ sudo vi /etc/docker/docker
# add this line
DOCKER_OPTS="--insecure-registry localhost:5000"
$ sudo service docker restart
$ sudo docker run -d -p 5000:5000 --name registry registry:2
$ sudo docker pull hello-world
These commands pull a public image from Docker Store, tag it for use in the private registry with the full name localhost:5000/hello-world, and then push it to the registry:
$ sudo docker tag hello-world localhost:5000/hello-world
$ sudo docker push localhost:5000/hello-world
On the local machine, you can remove the new image tag and the original image, and pull it again from the local registry to verify it was correctly stored:
$ sudo docker rmi localhost:5000/hello-world
$ sudo docker rmi hello-world
$ sudo docker pull localhost:5000/hello-world
$ sudo docker kill registry
$ sudo docker rm registry
In this example, the new container will use a host-mounted Docker volume. When the registry server in the container writes image layer data, it appears to be writing to a local directory in the container but it will be writing to a directory on the host.
Create a directory on the host machine for storing registry data $ mkdir registry-data
$ sudo docker run -d -p 5000:5000 \
--name registry \
-v `pwd`/registry-data:/var/lib/registry \
registry:2
$ docker tag hello-world localhost:5000/hello-world
$ docker push localhost:5000/hello-world
$ tree registry-data
$ sudo docker kill registry
$ sudo docker rm registry
It shall still show the content of the registry
$ tree registry-data