The test environment is as follows:
First, the installation of Docker
Installation method Please check the installation tutorial here
Second, set up ordinary users
1. How to set up CentOS
$ sudo gpasswd-a Docker ${user}
2. How to set up Ubuntu
$ sudo usermod-ag Docker ${user}
Third, the private library image download
1. Create a directory Private library mount
$ sudo mkdir-p/data/registry$ Docker run-d-P 5000:5000-v/data/registry:/tmp/registry Registry
2. View the downloaded image
$ docker Images
Iv. Configuration of the client
1. Download BusyBox test image
$ Docker Pull BusyBox
2. Set the label for BusyBox to upload to the private library
$ docker Tag 172.16.1.206:5000/busybox
V. The current version of Docker uses the HTTPS protocol by default, and some configuration is required to use the local repository. This configuration is performed on the client.
1, modify the/etc/default/docker
$ sudo vim/etc/default/docker
"/etc/default/docker"
docker_opts= "--registry-mirror=http://xxxxxxxx.m.daocloud.io--insecure-registry 172.16.1.206:5000--dns 8.8.8.8-- DNS 8.8.4.4 "
#上述设置关键在于172.16.1.206:5000
2, modify the/lib/systemd/system/docker.service
# Vim/lib/systemd/system/docker.service
"/lib/systemd/system/docker.service" Environmentfile=/etc/default/docker //This sentence is new Execstart=-/usr/bin/dockerd -H fd://$DOCKER _opts //reference docker_opts
#切换到root
$ sudo-i
# Systemctl Daemon-reload
# Systemctl Restart Docker
3. View the results of the changes
# The following command can be checked to see the docker_opts$ sudo systemctl status just set Docker.service
Vi. push mirroring to the local repository
$ docker Push 172.16.1.206:5000/busybox
UBUNTU16 Building Docker Private Library