Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to build a Docker Private Image Repository in CentOS7.2 Server

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

How to build a Docker private image repository in the CentOS7.2 server? In view of this problem, this article introduces the corresponding analysis and answers in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible way.

Install docker

# yum-y install docker# systemctl start docker & & systemctl enable docker

Use self-signature for security authentication

Create a certs directory where certificates and keys are stored

# mkdir-p / docker/certs# chcon-Rt svirt_sandbox_file_t / docker/certs/

Modify / etc/pki/tls/openssl.cnf configuration file

Add the IP address of the image repository in the [v3_ca] configuration item of the file:

[v3_ca] # Extensions for a typical CAsubjectAltName = IP:192.168.120.128

Generate certificates and keys

# cd / docker & & openssl req\-newkey rsa:4096-nodes-sha256-keyout certs/domain.key\-x509-days 365-out certs/domain.crt# mkdir-p / etc/docker/certs.d/192.168.120.128:5000/# cp certs/domain.crt / etc/docker/certs.d/192.168.120.128\: 5000/ca.crt

Create back-end storage for image files

# mkdir-p / docker/data/private_registry# chcon-Rt svirt_sandbox_file_t / docker/data/private_registry

Restart docker daemon

# systemctl restart docker

Start the private image repository

# docker run\-d\-- name private_registry-- restart=always\-u root\-p 5000 root 5000\-v / docker/data/private_registry:/var/lib/registry\-v / docker/certs:/certs\-e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/domain.crt\-e REGISTRY_HTTP_TLS_KEY=/certs/domain.key\ registry:2

Docker accelerator

The accelerator can be configured practically when the pull image is slow.

The copy code is as follows:

# curl-sSL https://get.daocloud.io/daotools/set_mirror.sh | sh-s http://c282dc88.m.daocloud.io

test

Local testing

# docker pull ubuntu# docker tag ubuntu 192.168.120.128:5000/ubuntu# docker pull 192.168.120.128:5000/ubuntuUsing default tag: latestTrying to pull repository 192.168.120.128:5000/ubuntu... latest: Pulling from 192.168.120.128:5000/ubuntuDigest: sha256:382452f82a8bbd34443b2c727650af46aced0f94a44463c62a9848133ecb1aa8

Remote testing

Execute the following command on another host to test:

# mkdir-p / etc/docker/certs.d/192.168.120.128:5000/# scp 192.168.120.128:/etc/docker/certs.d/192.168.120.128\: 5000/ca.crt / etc/docker/certs.d/192.168.120.128\: 5000 systemctl restart docker# docker pull 192.168.120.128:5000/ubuntuUsing default tag: latestTrying to pull repository 192.168.120.128:5000/ubuntu... latest: Pulling from 192 .168.120.128: 5000/ubuntub6f892c0043b: Pull complete55010f332b04: Pull complete2955fb827c94: Pull complete3deef3fcbd30: Pull completecf9722e506aa: Pull completeDigest: sha256:382452f82a8bbd34443b2c727650af46aced0f94a44463c62a9848133ecb1aa8 the answer to the question on how to build a Docker private image repository in the CentOS7.2 server is shared here. I hope the above content can help you to a certain extent, if you still have a lot of doubts to be solved, you can follow the industry information channel to learn more related knowledge.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report