Docker builds a local warehouse

Source: Internet
Author: User
Tags docker ps docker hub

The Docker Hub public repository has the following drawbacks:
1, strong network dependence, link speed limit;
2, privatization of information storage network is not secure
3, the privatization of the warehouse need to charge, there is a security risk

Solution uses local registry
Docker has already said registry open source, and also has an official image on the Docker hub registry
We can use it directly:
(1) Start Registry container
Shell>docker run-d-P 5000:5000-v/myregistry:/var/lib/registry registry:2
Mirroring using the Registry:2
-D Background Run
-P Talk Container 5000 ports mapped to 5000 ports on the host
-V Maps the container/var/lib/registry directory to the/myregistry/docker of the host to hold the mirrored data

Verify: Shell>docker PS to see if the warehouse container is started

(2) Download a test image locally
Shell>docker Pull CentOS

(3) Renaming the local mirror via Docker tag, matching with registry
Shell>docker tag CentOS Warehouse server address: 5000/user name/centos:v1
Shell>docker tag CentOS x.x.x.x:5000/testname/centos:v1
The full format of the repository is:

Docker Hub 上可以省略[registry-host]:[port],默认为docker.io

(4) Docker Pull/push test
Shell>docker Push X.X.X.X:5000/TESTNAME/CENTOS:V1
Shell>docker Pull X.x.x.x:5000/testname/centos:v1

(5) The uploaded image is in this directory
/myregistry/docker/registry/v2/repositories/docker39/cetnos_httpd/

Tips:
Shell>docker Pull X.x.x.x:5000/testname/cetnos
Using default Tag:latest
Error response from Daemon:get https://x.x.x.x:5000/v2/: Http:server gave HTTP response to HTTPS client
This is Docker does not support HTTPS
CentOS System through: Modify or add Daemon.json file, restart Docker service can
Shell>vim/etc/sysconfig/daemon.json
{"Insecure-registries": ["x.x.x.x:5000"]}

Shell>systemctl Restart Docker//Restart service, remember to start the Registry warehouse container

Docker Build Local warehouse

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.