Docker supports registry to support image distribution and update management. This greatly facilitates users.
The official website dockerhub is provided as a public centralized repository. However, local access to dockerhub is often slow, and many times we need a local private repository for internal use only.
There are many articles about how to create and use a local repository.
However, these articles either have outdated content or provide incorrect configurations, resulting in failure to create a repository.
First, we need to introduce the principle.
The docker repository provides two functions: image management and authentication.
The former is mainly implemented by the docker-registry project and uploaded and downloaded through the HTTP service. The latter can be implemented through the docker-index project or the existing authentication scheme.
We will not discuss how to implement authentication today.
Since docker-Registry is also a software application, the simplest method is to use the officially deployed image registry.
The official documentation also provides suggestions for running the sudo docker run-P 5000: 5000 registry command directly. In this way, a Registry server can be started, but all the uploaded images are managed by the docker container and placed in a directory of/var/lib/docker. The image will also be deleted once the container is deleted.
Therefore, we need to find a way to tell the docker container where the image should be stored.
After the Registry image is started, the default location of the image is/tmp/Registry. Therefore, you can directly map the location to the local/opt/data/Registry directory.
You can use commands
Sudo dockerrun-D-P 5000: 5000-V/opt/data/Registry:/tmp/Registry
In this way, you do not need to specify configuration files or other complex configurations.
More specific content, you can refer to the http://yeasy.gitbooks.io/docker_practice/repository/local_repo.html
Recommended method for creating a docker local repository