Experimental environment: Two centos7 virtual machines, one is server, used as the client, and the other is registry, used as the docker private image repository.
Basic Configuration
Check the IP addresses of the two VMS.
The IP address of the server is192.168.134.151
.
The IP address of the Registry is192.168.134.150
.
Usesetenforce 0
Temporarily disable SELinux.
OpenServer
AndRegistry
Kernel forwarding function
Edit configuration file/etc/sysctl.conf
, Add the following content:
net.ipv4.ip_forward = 1 net.ipv4.conf.default.rp_filter = 0 net.ipv4.conf.all.rp_filter = 0
Usesysctl –p
Command.
Docker Configuration
1. Install the docker Environment
InServer
AndRegistry
Use on two machinesyum install -y docker
Command to install the docker environment.
2. Configure the docker configuration file
InServer
AndRegistry
Edit on/etc/sysconfig/docker
Add the following two lines to the file:
ADD_REGISTRY='--add-registry 192.168.134.150:5000' INSECURE_REGISTRY='--insecure-registry 192.168.134.150:5000'
Here we willdocker image
To the local privateRegistry
.
Usesystemctl restart docker
Command to restart docker.
3. Set the docker Service
Set docker to start automatically
systemctl enable docker
4. Configure the image repository
First, put the tar packages of the two images to be used./root
Directory.
Then manually load the image and Loadregistry
And then upload the image to the private image repository becauseregistry
The container must be used for registration of other containers.To build a private image repository, you must first start the Registry container.
The command used is as follows:
Docker load <registry_latest.tar // load the image docker images // view the newly loaded image's iddocker run-D-P 5000: 5000 -- restart = always -- Name Registry registry: latest // start the Registry container docker tag image ID Registry: Latest // create a new tag for the Registry image (skip this step) docker push registry: latest // upload the Registry image to the private image repository (skip this step)
Usedocker images
Check the local image.
You can see the following is the image I just re-tagged.
Upload an owncloud image.
Here we can see that the uploaded image has no tag, so we can tag it.
Then upload the image to the private image repository.
All commands are as follows:
Docker load <owncloud.tar // load the image docker images // view the newly loaded image's iddocker tag image ID owncloud: Latest // Add tagdocker push owncloud to the owncloud image: latest // upload the owncloud image to the private image repository
The default location of my private image repository is/var/lib/docker/volumes/022dbe58afaec96083a1ceb3fb6672c7a62be38a5a48158322d75d2e6b1150c3/_data/docker/registry/v2/repositories/
.
View
Here we can see the image files uploaded to the private image repository.
Verify
Verify that the private image is successfully built.
Pull the owncloud image to the server and try it out.
Here we can see that he is from192.168.134.150 Registry
The image pulled from the image repository.
This experiment is successful!
Manually build a docker local private image repository