千家信息网

怎么用docker-registry源码构建仓库

发表于:2025-12-03 作者:千家信息网编辑
千家信息网最后更新 2025年12月03日,这篇文章主要讲解了"怎么用docker-registry源码构建仓库",文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习"怎么用docker-registry
千家信息网最后更新 2025年12月03日怎么用docker-registry源码构建仓库

这篇文章主要讲解了"怎么用docker-registry源码构建仓库",文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习"怎么用docker-registry源码构建仓库"吧!

进行编译

[root@localhost docker-registry]# docker build -t "heidsoft-registry" .

Sending build context to Docker daemon

FATA[0000] Post http:///var/run/docker.sock/v1.18/build?cgroupparent=&cpusetcpus=&cpushares=0&dockerfile=Dockerfile&memory=0&memswap=0&rm=1&t=heidsoft-registry: dial unix /var/run/docker.sock: no such file or directory. Are you trying to connect to a TLS-enabled daemon without TLS?

[root@localhost docker-registry]# systemctl start dcoker

Failed to issue method call: Unit dcoker.service failed to load: No such file or directory.

[root@localhost docker-registry]# systemctl start docker

```


```

成功在本地通过源码构建了镜像仓库,总共经历了12步:

@....start

building 'markupsafe._speedups' extension

x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c markupsafe/_speedups.c -o build/temp.linux-x86_64-2.7/markupsafe/_speedups.o

x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -D_FORTIFY_SOURCE=2 -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/markupsafe/_speedups.o -o build/lib.linux-x86_64-2.7/markupsafe/_speedups.so

Successfully installed docker-registry backports.lzma blinker Flask gevent gunicorn PyYAML requests M2Crypto sqlalchemy bugsnag Flask-cors newrelic Werkzeug Jinja2 itsdangerous greenlet webob markupsafe

Cleaning up...

---> bb135fe1c419

Removing intermediate container 5561b2fef818

Step 8 : RUN patch $(python -c 'import boto; import os; print os.path.dirname(boto.__file__)')/connection.py < /docker-registry/contrib/boto_header_patch.diff

---> Running in bc90ae3350bb

patching file /usr/local/lib/python2.7/dist-packages/boto/connection.py

---> c4fc4bf464b2

Removing intermediate container bc90ae3350bb

Step 9 : ENV DOCKER_REGISTRY_CONFIG /docker-registry/config/config_sample.yml

---> Running in fc182d9daed0

---> 9b16c0a3aaf8

Removing intermediate container fc182d9daed0

Step 10 : ENV SETTINGS_FLAVOR dev

---> Running in ebae054b90fb

---> 1b4a1e134805

Removing intermediate container ebae054b90fb

Step 11 : EXPOSE 5000

---> Running in 648f41896bbf

---> c3736b5cf3ab

Removing intermediate container 648f41896bbf

Step 12 : CMD docker-registry

---> Running in 3af3b4d0c90c

---> 80aa76e58d06

Removing intermediate container 3af3b4d0c90c

Successfully built 80aa76e58d06

@...end

运行编译出来的镜像

docker run -d --privileged -e SETTINGS_FLAVOR=dev -e STORAGE_PATH=/opt/registry -v /db/docker-images:/opt/registry -p 5000:5000 heidsoft-registry

加入认证环境

wget http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

rpm -ivh nginx-release-centos-7-0.el7.ngx.noarch.rpm

yum install nginx

wget -c soft.vpser.net/lnmp/ext/htpasswd.sh

创建两个登录用户

[root@heidsoft ~]# ./htpasswd.sh -c /etc/nginx/docker-registry.htpasswd heidsoft

=====================================

# A tool like htpasswd for Nginx #

#-----------------------------------#

# Author:Licess http://www.lnmp.org #

=====================================

Please input UserName:heidsoft

===========================

UserName was: heidsoft

===========================

Please input the Password:heidsoft

===========================

Password was: heidsoft

===========================

Please input Auth filename:heidsoft

===========================

Auth File: /usr/local/nginx/conf/heidsoft

===========================


[root@heidsoft ~]# ./htpasswd.sh -c /etc/nginx/docker-registry.htpasswd liubin

=====================================

# A tool like htpasswd for Nginx #

#-----------------------------------#

# Author:Licess http://www.lnmp.org #

=====================================

Please input UserName:liubin

===========================

UserName was: liubin

===========================

Please input the Password:liubin

===========================

Password was: liubin

===========================

Please input Auth filename:liubin

===========================

Auth File: /usr/local/nginx/conf/liubin

===========================


Press any key to Creat...or Press Ctrl+c to cancel

Create Auth file......

./htpasswd.sh: line 64: /usr/local/nginx/conf/liubin.conf: No such file or directory

Create Auth file successful,auth file path:/usr/local/nginx/conf/liubin.conf.

[root@heidsoft ~]#


nginx 错误日志


```

curl http://liubin:liubin@heidsoft.registry:8080/v1/search

2015/07/18 06:58:24 [crit] 35545#0: *1 connect() to 127.0.0.1:5000 failed (13: Permission denied) while connecting to upstream, client: 192.168.1.6, server: heidsoft.registry, request: "GET /v1/search HTTP/1.1", upstream: "http://127.0.0.1:5000/v1/search", host: "heidsoft.registry:8080"

2015/07/18 06:58:24 [crit] 35545#0: *1 connect() to [::1]:5000 failed (13: Permission denied) while connecting to upstream, client: 192.168.1.6, server: heidsoft.registry, request: "GET /v1/search HTTP/1.1", upstream: "http://[::1]:5000/v1/search", host: "heidsoft.registry:8080"

```


临时关闭selinux后能根据认证文件请求到

```

setenforce 0

感谢各位的阅读,以上就是"怎么用docker-registry源码构建仓库"的内容了,经过本文的学习后,相信大家对怎么用docker-registry源码构建仓库这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是,小编将为大家推送更多相关知识点的文章,欢迎关注!

仓库 源码 学习 内容 镜像 编译 认证 成功 两个 就是 思路 情况 文件 文章 日志 更多 环境 用户 知识 知识点 数据库的安全要保护哪些东西 数据库安全各自的含义是什么 生产安全数据库录入 数据库的安全性及管理 数据库安全策略包含哪些 海淀数据库安全审计系统 建立农村房屋安全信息数据库 易用的数据库客户端支持安全管理 连接数据库失败ssl安全错误 数据库的锁怎样保障安全 我想学软件开发零基础 会议呼叫服务器 网络技术春考理论大纲 互联网高科技公司有哪些 国家网络安全宣传周新沂在行动 软件开发项目的服务承诺 查询当前数据库中表的语句 我的世界服务器花屏 施乐700服务器亮光模式 苏州手机应用软件开发怎样收费 1151接口服务器 自学软件开发经验 数据库组合框是对象吗 oa软件开发协议范本 基岩版仿2b2t服务器大全 数据库忘记密码怎么找回来 推理小说男主是学习网络技术的 程序员做软件开发遇到瓶颈期 网络安全橱窗设计方案 软件开发服务费增值税征收品目 数据库资源申请理由 上海物际网络技术有限公司 excel是一个小型数据库管理系统吗 信息网络安全管理规定第九条 鱼池服务器-1200是什么意思 网络技术三级题库 阳光网络技术 许福生 家用网络能做服务器网络么 软件开发和设计哪个先 网络安全顾问主要表现方面
0