Build environment:
MacOS Sierra 10.12.4(Darwin Kernel Version 16.5.0)
Docker version 17.03.1-ce
Preparation before building:
1. Install docker and run it normally
2. Find the image registry to build the local warehouse on the docker official website
The official registry image is provided on Docker hub. We can directly use the registry image to build a container and build our own private warehouse service.
The specific construction method is as follows:
1. Pull the image from docker hub
docker pull registry:latest
2. Create a local image warehouse storage path
mdkir path/to/registry
3. The storage path of the local image warehouse needs to be shared
Docker -> Preferences... -> File Sharing
Add the folder to the share
4. Start the container
docker run -d -v path/to/registry:/var/lib/registry -p 5000:5000 --restart=always --name registry registry:latest
The Registry service will save the uploaded image in the container's /var/lib/registry by default. We can save the image by mounting the host's path/to/registry directory to this directory. Go to the path/to/registry directory of the host.
5. Check whether the registry service is started
$ docker ps
6. Push the local image into the local image warehouse
docker tag workspace:latest 127.0.0.1:5000/workspace:latest docker push 127.0.0.1:5000/workspace
7. Verify whether it has been pushed to the local image warehouse
http://127.0.0.1:5000/v2/_catalog
Recommended tutorial: docker tutorial
The above is the detailed content of Can docker build a local mirror warehouse?. For more information, please follow other related articles on the PHP Chinese website!