Build a private repository using register images in CoreOS
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. This article describes how to create a local Repo using a register Image Based on the CoreOS system.
1. Use registry to start a private repository container
Docker run-d-p 5000: 5000-v/root/my_registry:/tmp/registry
Note: If the registry container is not installed before, a registry container is automatically downloaded and started to create a local private repository service. By default, the repository is created in the/tmp/registry directory of the container. You can use the-v parameter to store the image file in a specified local path (for example, in the local directory/root/my_registry ).
2. push an image to a private Repository
After the register image is started, upload the register image to the local repository for testing.
Note: According to the IP address and Port of the host where the registry container is started in step 1, push the local container of an environment.
Localhost images # docker push 10.0.0.142: 5000/register
The push refers to a repository [10.0.0.142: 5000/register] (len: 1)
Sending image list
Pushing repository 10.0.0.142: 5000/register (1 tags)
E9e06b06e14c: Image successfully pushed
A82efea989f9: Image successfully pushed
37bea4ee0c81: Image successfully pushed
07f8e8c5e660: Image successfully pushed
1f4ab7282e19: Image successfully pushed
0e4483abe66b: Image successfully pushed
C6153b5d8f1f: Image successfully pushed
2bc4611f2ed7: Image successfully pushed
30887473610f: Image successfully pushed
3f8e22c413b1: Image successfully pushed
22b1c756fa19: Image successfully pushed
90607d8d09d1: Image successfully pushed
4f4a5acb19eb: Image successfully pushed
204704ce3ed: Image successfully pushed
Pushing tag for rev [204704ce3133] on {http: // 10.0.0.142: 5000/v1/repositories/register/tags/latest}
Directory structure of the host my_registry
Localhost my_registry # ls-R
.:
Images repositories
./Images:
20172bc4611f2ed7611f46c4aaee05e34b7a490671c79c41b827dc168377da95b041 then
201710000a82efea989f94b1d9fac76e26e37b0bbde11047a3afcaa47064949dfa3b3209b
201737bea4ee0c816e3a3fa025f36450ef8ef0817b3f8fcd7b49eb7b26064f647bb0 then
204704ce31375bcf4afecf672563b4881bbef0d59135c68d273235bb7254fb4b 201710000large
Zookeeper
./Images/07f8e8c5e66084bef8f848877857537ffe1c47edd01a93af27e7161672ad0e95:
_ Checksum ancestry json layer
./Images:
_ Checksum ancestry json layer
./Images:
_ Checksum ancestry json layer
./Images/204704ce31375bcf4afecf672563b4881bbef0d59135c68d273235bb7254fb4b:
_ Checksum ancestry json layer
./Images:
_ Checksum ancestry json layer
./Images/2bc4611f2ed7611f46c4aaee05e34b7a490671c79c41b827dc168377da95b041:
_ Checksum ancestry json layer
./Images/30887473610f3f9354a34931cc43b8dd744d93375d6d95704d41513f843008dd:
_ Checksum ancestry json layer
./Images/37bea4ee0c816e3a3fa025f361_ef8ef0817b3f8fcd7b49eb7b26064f647bb0:
_ Checksum ancestry json layer
./Images:
_ Checksum ancestry json layer
./Images:
_ Checksum ancestry json layer
./Images:
_ Checksum ancestry json layer
./Images/a82efea989f94b1d9fac76e26e37b0bbde11047a3afcaa47064949dfa3b3209b:
_ Checksum ancestry json layer
./Images:
_ Checksum ancestry json layer
./Images:
_ Checksum ancestry json layer
./Repositories:
Library
./Repositories/library:
Register
./Repositories/library/register:
_ Index_images json tag_latest taglatest_json
Questions about https
Root @ gerryyang :~ # Docker push 104.131.173.242: 5000/Ubuntu_sshd_gcc_gerry: 14.04
FATA [0002] Error: Invalid registry endpoint https: // 104.131.173.242: 5000/v1/: Get https: // 104.131.173.242: 5000/v1/_ ping: EOF. if this private registry supports only HTTP or HTTPS with an unknown CA certificate, please add' -- insecure-registry 104.131.173.242: 5000 'to the daemon's arguments. in the case of HTTPS, if you have access to the registry's CA certificate, no need for the flag; simply place the CA certificate at/etc/docker/certs. d/104.131.173.242: 5000/ca. crt
Solution:
Solution:
Vi/usr/lib/systemd/system/docker. service
Modify the content as follows:
[Unit]
Description = Docker Application Container Engine
Documentation = http://docs.docker.com
Afterappsnetwork.tar get docker. socket
Requires = docker. socket
[Service]
Type = Policy
EnvironmentFile =-/etc/sysconfig/docker
EnvironmentFile =-/etc/sysconfig/docker-storage
ExecStart =/usr/bin/docker-d -- insecure-registry 10.0.0.142: 5000-H fd: // $ OPTIONS $ DOCKER_STORAGE_OPTIONS
Maid = 1048576
LimitNPROC = 1048576
[Install]
Wantedbypolicmulti-user.tar get
In CoreOS, method 1 may encounter/usr/lib/systemd/system/docker. when the service file ReadOnly cannot be modified, You can manually start and add the -- insecure-registry Parameter
Localhost ~ #/Usr/lib/coreos/dockerd -- daemon -- insecure-registry 10.0.0.142: 5000
3. Private repository Query Method
Curl http: // 10.0.0.0.142: 5000/v1/search
Note: Use curl to view images in the repository 104.131.173.242: 5000. You can view ubuntu_sshd_gcc_gerry in the result, indicating that the upload is successful.
4. access and download private repository images from other machines
Manually start docker: localhost ~ on the client ~ #/Usr/lib/coreos/dockerd -- daemon -- insecure-registry 10.0.0.142: 5000
Run the pull command
Localhost ~ # Docker pull 10.0.0.142: 5000/jdk7
Pulling repository 10.0.0.142: 5000/jdk7
134625e9d4d7: Download complete
134625e9d4d7: Pulling image (latest) from 10.0.0.142: 5000/jdk7
6941 bfcbbfca: Download complete
41459f052977: Download complete
Fd44297e2ddb: Download complete
40eba1bcf993: Download complete
E60bdcf6f45f: Download complete
367c013cf9ca: Download complete
81812b96beec: Download complete
776f6d47bdf7: Download complete
2c96f979a63a: Download complete
F33b1fffe108: Download complete
71f589de03a8: Download complete
2115aa302043: Download complete
6a498e83fe1b: Download complete
591be66f0e03: Download complete
C468a9de6202: Download complete
A510d6919954: Download complete
14b73f7c3942: Download complete
B591b7e6f5da: Download complete
F1a90a0630e1: Download complete
Unzip a069bbe25: Download complete
Status: Downloaded newer image for 10.0.0.142: 5000/jdk7: latest