溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

怎么用docker-registry源碼構(gòu)建倉庫

發(fā)布時間:2021-08-17 20:19:17 來源:億速云 閱讀:179 作者:chen 欄目:云計算

這篇文章主要講解了“怎么用docker-registry源碼構(gòu)建倉庫”,文中的講解內(nèi)容簡單清晰,易于學(xué)習(xí)與理解,下面請大家跟著小編的思路慢慢深入,一起來研究和學(xué)習(xí)“怎么用docker-registry源碼構(gòu)建倉庫”吧!

進行編譯

[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

```


```

成功在本地通過源碼構(gòu)建了鏡像倉庫,總共經(jīng)歷了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

加入認證環(huán)境

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

創(chuàng)建兩個登錄用戶

[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"

```


臨時關(guān)閉selinux后能根據(jù)認證文件請求到

```

setenforce 0

感謝各位的閱讀,以上就是“怎么用docker-registry源碼構(gòu)建倉庫”的內(nèi)容了,經(jīng)過本文的學(xué)習(xí)后,相信大家對怎么用docker-registry源碼構(gòu)建倉庫這一問題有了更深刻的體會,具體使用情況還需要大家實踐驗證。這里是億速云,小編將為大家推送更多相關(guān)知識點的文章,歡迎關(guān)注!

向AI問一下細節(jié)

免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI