Skip to content

Instantly share code, notes, and snippets.

@touren
Last active June 22, 2016 21:45
Show Gist options
  • Save touren/0b7f5c227a0d5da7efbc020523c49e29 to your computer and use it in GitHub Desktop.
Save touren/0b7f5c227a0d5da7efbc020523c49e29 to your computer and use it in GitHub Desktop.
Deploying a plain HTTP registry to share your local docker images.
Referenced from:
https://docs.docker.com/registry/insecure/
https://linuxconfig.org/how-to-run-your-own-local-private-docker-registry
Deploying a plain HTTP registry
This basically tells Docker to entirely disregard security for your registry. While this is relatively easy to configure the daemon in this way, it is very insecure. It does expose your registry to trivial MITM. Only use this solution for isolated testing or in a tightly controlled, air-gapped environment.
Open the /etc/default/docker file or /etc/sysconfig/docker for editing.
Depending on your operating system, your Engine daemon start options.
Edit (or add) the DOCKER_OPTS line and add the --insecure-registry flag.
This flag takes the URL of your registry, for example.
DOCKER_OPTS="--insecure-registry myregistrydomain.com:5000"
Close and save the configuration file.
Restart your Docker daemon
The command you use to restart the daemon depends on your operating system. For example, on Ubuntu, this is usually the service docker stop and service docker start command.
Repeat this configuration on every Engine host that wants to access your registry.
# docker run -d -p 5000:5000 registry
e6f9480e94ea30a4a400f499b9e28dfac87ccd3ccb59627e78fe784249248127
Next from a client host, use docker command to obtain an IMAGE-ID of the docker image you wish to push to your local repository:
# docker images
Take a note of the IMAGE ID eg. 41b730702607. Now that we have an IMAGE ID of the docker image we would like to upload to our own local docker registry we can use docker tag command to tag this image for an upload:
# docker tag 41b730702607 linuxconfig.docker.local:5000/debian:8
Once we have tagged our image we can use docker push command to upload it our local docker registry:
# docker push linuxconfig.docker.local:5000/debian:8
The push refers to a repository [linuxconfig.docker.local:5000/debian] (len: 1)
Sending image list
Pushing repository linuxconfig.docker.local:5000/debian (1 tags)
3cb35ae859e7: Image successfully pushed
41b730702607: Image successfully pushed
Pushing tag for rev [41b730702607] on {http://linuxconfig.docker.local:5000/v1/repositories/debian/tags/8}
Lastly, search your local Docker registry to confirm a correct upload:
# docker search linuxconfig.docker.local:5000/debian
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
library/debian
# docker pull linuxconfig.docker.local:5000/debian
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment