Today I’ll show you how to create a private Docker registry. Note however you should use it only for development and testing purposes!
Preconditions
- docker-machine installed
Preparation
# create new vms my-registry and my-workspace $ docker-machine create -d virtualbox my-registry && docker-machine create -d virtualbox my-workspace # show created vms $ docker-machine ls NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS my-registry - virtualbox Running tcp://192.168.99.100:2376 v1.11.0 my-workspace - virtualbox Running tcp://192.168.99.101:2376 v1.11.0
Create and run Docker registry container
# pointing shell to my-registry $ eval $(docker-machine env my-registry) # create new container (registry version 2) $ docker run -d -p 5000:5000 --name registry-v2 --restart=always registry:2 # show created container on my-registry $ docker ps -a
Prepare and push into registry
# ssh into my-workspace $ docker-machine ssh my-workspace # modify profile $ sudo vi /var/lib/boot2docker/profile # add new content like: EXTRA_ARGS=' --label provider=virtualbox --insecure-registry 192.168.99.100:5000 ' # close ssh $ exit # restart my-workspace $ docker-machine restart my-workspace # pointing shell to my-workspace $ eval $(docker-machine env my-workspace) # pull a public image $ docker pull centos:centos7 # create new tag $ docker tag centos:centos7 192.168.99.100:5000/lupin/centos7 # show images (2 images should be there) $ docker images # push image $ docker push 192.168.99.100:5000/lupin/centos7
Create registry Browser-UI
# create new vm my-registry-gui $ docker-machine create -d virtualbox my-registry-gui # pointing shell to my-registry-gui $ eval $(docker-machine env my-registry-gui) # create new container $ docker run -d -p 8080:80 -e ENV_DOCKER_REGISTRY_HOST=192.168.99.100 -e ENV_DOCKER_REGISTRY_PORT=5000 --name registry-v2-gui --restart=always konradkleine/docker-registry-frontend:v2 # show created container $ docker ps -a # show created vms $ docker-machine ls NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS my-registry - virtualbox Running tcp://192.168.99.100:2376 v1.11.0 my-registry-gui * virtualbox Running tcp://192.168.99.102:2376 v1.11.0 my-workspace - virtualbox Running tcp://192.168.99.101:2376 v1.11.0
Run browser