1. 程式人生 > >配置docker本地倉庫遇到的一些問題

配置docker本地倉庫遇到的一些問題

配置docker本地倉庫

在執行一下命令的時候遇到一些問題,記錄如下:


000


# pip install docker-registry


Searching for M2Crypto==0.22.3

Reading https://pypi.python.org/simple/M2Crypto/

Best match: M2Crypto 0.22.3

Downloading https://pypi.python.org/packages/source/M/M2Crypto/M2Crypto-0.22.3.tar.gz#md5=573f21aaac7d5c9549798e72ffcefedd

Processing M2Crypto-0.22.3.tar.gz

Writing /tmp/easy_install-vVPR1Z/M2Crypto-0.22.3/setup.cfg

Running M2Crypto-0.22.3/setup.py -q bdist_egg --dist-dir /tmp/easy_install-vVPR1Z/M2Crypto-0.22.3/egg-dist-tmp-3c7TJ3

SWIG/_m2crypto.i:30: Error: Unable to find 'openssl/opensslv.h'

SWIG/_m2crypto.i:33: Error: Unable to find 'openssl/safestack.h'

SWIG/_evp.i:12: Error: Unable to find 'openssl/opensslconf.h'

SWIG/_ec.i:7: Error: Unable to find 'openssl/opensslconf.h'

error: Setup script exited with error: command 'swig' failed with exit status

解決辦法是安裝 openssl-devel:


# yum install -y openssl-devel.x86_64

001


重新執行 pip install docker-registry


Searching for M2Crypto==0.22.3

Reading https://pypi.python.org/simple/M2Crypto/

Best match: M2Crypto 0.22.3

Downloading https://pypi.python.org/packages/source/M/M2Crypto/M2Crypto-0.22.3.tar.gz#md5=573f21aaac7d5c9549798e72ffcefedd

Processing M2Crypto-0.22.3.tar.gz

Writing /tmp/easy_install-5hkA4l/M2Crypto-0.22.3/setup.cfg

Running M2Crypto-0.22.3/setup.py -q bdist_egg --dist-dir /tmp/easy_install-5hkA4l/M2Crypto-0.22.3/egg-dist-tmp-pZ_OGN

/usr/include/openssl/opensslconf.h:36: Error: CPP #error ""This openssl-devel package does not work your architecture?"". Use the -cpperraswarn option to continue swig processing.

error: Setup script exited with error: command 'swig' failed with exit status

解決辦法是手動安裝 M2Crypto 0.22.3 (M2Crypto 0.22.3在centos7上安裝會有一些問題需要借助腳本)


1. 下載 M2Crypto-0.22.3.tar.gz


wget https://pypi.python.org/packages/source/M/M2Crypto/M2Crypto-0.22.3.tar.gz #下載源碼

tar zxvf M2Crypto/M2Crypto-0.22.3.tar.gz # 解壓

cd M2Crypto-0.22.3

2. 然後創建安裝腳本,內容如下:


# vim fedora_setup.sh

#!/bin/sh

# This script is meant to work around the differences on Fedora Core-based# distributions (Redhat, CentOS, ...) compared to other common Linux

# distributions.

#

# Usage: ./fedora_setup.sh [setup.py options]

#


arch=`uname -m`

for i in SWIG/_{ec,evp}.i; do

sed -i -e "s/opensslconf\./opensslconf-${arch}\./" "$i"

done


SWIG_FEATURES=-cpperraswarn python setup.py $*

3. 然後為腳本添加執行權限,執行腳本,並安裝M2Crypto 0.22.3


# chmod +x fedora_setup.sh

# ./fedora_setup.sh build

# python setup.py install

至此可以完成安裝,需要註意的是私有倉庫的配置文件 config_sample.yml在以下路徑


/usr/lib/python2.7/site-packages/docker_registry-1.0.0_dev-py2.7.egg/config

002


配置完成後啟動服務,push鏡像的時候又有如下錯誤:


docker pull 172.16.18.159:5000/ubuntu:12.04

Error: Invalid registry endpoint https://172.16.18.159:5000/v1/: Get https://172.16.18.159:5000/v1/_ping: EOF. If this private registry supports only HTTP or HTTPS with an unknown CA certificate, please add `--insecure-registry http://172.16.18.159:5000` to the daemon's arguments. In the case of HTTPS, if you have access to the registry's CA certificate, no need for the flag; simply place the CA certificate at /etc/docker/certs.d/http://172.16.18.159:5000/ca.crt

解決方法是在docker的配置文件裏面OPTIONS添加 –insecure-registry http://172.16.18.159:5000 選項


# /etc/sysconfig/docker


# Modify these options if you want to change the way the docker daemon runs

OPTIONS='--selinux-enabled --insecure-registry 172.16.18.159:5000'

DOCKER_CERT_PATH=/etc/docker

然後重啟docker服務:


# systemctl restart docker

至此錯誤全部解決,本地倉庫配置成功


配置docker本地倉庫遇到的一些問題