怎么用docker-registry源码构建仓库
这篇文章主要讲解了“怎么用docker-registry源码构建仓库”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“怎么用docker-registry源码构建仓库”吧!
创新互联建站提供成都做网站、网站设计、网页设计,品牌网站制作,1元广告等致力于企业网站建设与公司网站制作,10年的网站开发和建站经验,助力企业信息化建设,成功案例突破上1000家,是您实现网站建设的好选择.
进行编译
[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源码构建仓库这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是创新互联,小编将为大家推送更多相关知识点的文章,欢迎关注!
网页题目:怎么用docker-registry源码构建仓库
链接URL:http://pwwzsj.com/article/pdcihj.html