The most direct way to preserve and disseminate the image is to use Docker H ub, which is maintained by the company Docker public Regsitry, users can save their own image to Docker H ub free of the repository. If you do not want others to access your images, you can also buy private repository.
Generally, we can use the Docker H ub upload and download the image, though very convenient, but there are some restrictions, such as:
1, requires external network connections, and upload and download speeds slow
2, upload Docker H ub mirrored anyone can access, although you can use private repositroy, but not free
3, for security reasons many organizations do not allow the image into the external network
The solution is a single room local Registry.
Docker has the Registry open while the Docker H ub also has an official mirror Registry.
We can run your own Registry in Docker in
Use dockerfile build httpd
Before using warehouse, first we build a httpd image, save it to the local
first create dockerfile directories and files created dokcerfile
cd ~
mkdir dokcerfile
cd dockerfile
touch dockerfie
Edit follows dockerfile
then builds an http mirror
docker build -t httpd:v11 -f dockerfile /root/dockerfile
As shown below, was successfully constructed
check image
docker images
Start registry container
First created in the root directory / myregistry directory for storing image data of
the current mirror is used registry: 2
cd /
mkdir /myregistry
Use the following command to create a registry container
docker run -d -p 5000:5000 -v /myregistry:/var/lib/registry registry:2
Description:
. 1, -d background starting container
2, -p mapped to port 5000 of container 5000 to Host port. 5000 is a registry service port
3, -v the container / var / lib / regsitry Host mapped to the directory / myregistry, for storing image data
By renaming docker tag image, so that the matching registry, as follows:
docker tag yangchao/httpd:v1 127.0.0.1:5000/yangchao/httpd:v1
The httpd: v11 change the format Registry requirements in the following format:
Only the mirror may be omitted Docker Hub registry-host: [port]
in the following manner, by renaming docker tag image, so that the matching registry
docker tag httpd:v11 127.0.0.1:5000/yangchao/httpd:v11
Use dokcer image command to check the mirror
Then yangchao / httpd: v11 uploaded to the Registry
docker push 127.0.0.1:5000/yangchao/httpd:v11
And then view the Registry in the mirror
curl 127.0.0.1:5000/v2/_catalog
You can view the image in / myregistry directory
so far has been created on the local registry