Running local fresh docker in a terminal:
mkdir -p /home/core/docker1
sudo docker -d -g /home/core/docker1 -p /var/run/docker1.pid -H tcp://127.0.0.1:5011
Pulling ubuntu image from public registry into that docker (in another terminal):
$ docker -H tcp://localhost:5011 pull ubuntu:13.04
Pulling repository ubuntu
eb601b8965b8: Download complete
511136ea3c5a: Download complete
f323cf34fd77: Download complete
$ docker -H tcp://localhost:5011 images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
ubuntu 13.04 eb601b8965b8 6 days ago 166.5 MB
Run a private registry (within a docker container, hey, why not?)
git clone https://github.com/drnic/docker-registry-dockerfile.git
cd docker-registry-dockerfile
git submodule update --init
docker -H tcp://localhost:5011 build -t registry .
docker -H tcp://localhost:5011 run -p 5000:5000 -v $(pwd)/cache:/registry registry
Note, the stored files of this private registry is on the host machine and so will survive restarts of the docker-registry docker container.
Tag and push the downloaded image to the private registry:
$ docker -H tcp://localhost:5011 tag ubuntu:13.04 localhost:5000/ubuntu-13.04
$ docker -H tcp://localhost:5011 push localhost:5000/ubuntu-13.04
The push refers to a repository [localhost:5000/ubuntu-13.04] (len: 1)
Sending image list
Pushing repository localhost:5000/ubuntu-13.04 (1 tags)
511136ea3c5a: Image successfully pushed
f323cf34fd77: Image successfully pushed
eb601b8965b8: Image successfully pushed
Pushing tags for rev [eb601b8965b8] on {http://localhost:5000/v1/repositories/ubuntu-13.04/tags/latest}
Running local fresh docker in another terminal:
mkdir -p /home/core/docker2
sudo docker -d -g /home/core/docker2 -p /var/run/docker2.pid -H tcp://127.0.0.1:5012
Now, you can run a new container in the new docker daemon based on the private registry image:
$ docker -H tcp://localhost:5012 run localhost:5000/ubuntu-13.04 echo hello world
Unable to find image 'localhost:5000/ubuntu-13.04' (tag: latest) locally
Pulling repository localhost:5000/ubuntu-13.04
f323cf34fd77: Download complete
511136ea3c5a: Download complete
eb601b8965b8: Download complete
hello world
Now the fresh docker daemon has the private localhost:5000/ubuntu-13.04
repository downloaded and can be reused again quickly:
$ docker -H tcp://localhost:5012 run localhost:5000/ubuntu-13.04 echo hello world
hello world