Docker環境編譯時的錯誤記錄

散盡浮華發表於2018-05-13

 

1)報錯一
docker-compose -f compose/app.yaml -f compose/backend.yaml -f compose/proxy.yaml build peatio barong
ERROR: Couldn't connect to Docker daemon at http://localhost:4243 - is it running?

If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.
make: *** [build] Error 1

解決辦法:

1)檢視配置檔案
[root@docker-server ~]# systemctl show docker | grep FragmentPath=
FragmentPath=/usr/lib/systemd/system/docker.service

然後修改/lib/systemd/system/docker.service檔案
[root@docker-server ~]# cp /lib/systemd/system/docker.service /lib/systemd/system/docker.service.bak
[root@docker-server ~]# vim /lib/systemd/system/docker.service
.......
ExecStart=/usr/bin/dockerd -H unix:///var/run/docker.sock -H tcp://0.0.0.0:4243                  #新增這一行
#ExecStart=/usr/bin/dockerd-current \                                                            #註釋掉預設的這一行
          --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current \        
          --default-runtime=docker-runc \
          --exec-opt native.cgroupdriver=systemd \
          --userland-proxy-path=/usr/libexec/docker/docker-proxy-current \
          --seccomp-profile=/etc/docker/seccomp.json \
          $OPTIONS \
          $DOCKER_STORAGE_OPTIONS \
          $DOCKER_NETWORK_OPTIONS \
          $ADD_REGISTRY \
          $BLOCK_REGISTRY \
          $INSECURE_REGISTRY \
    $REGISTRIES

2)修改/etc/default/docker檔案
[root@docker-server ~]# cp /etc/default/docker /etc/default/docker.bak
[root@docker-server ~]# vim /etc/sysconfig/docker
......
DOCKER_OPTS="-H tcp://localhost:4243 -H unix:///var/run/docker.sock"          #新增這一行

3)DOCKER_HOST的環境變數設定
[root@docker-server ~]# vim ~/.bashrc 
........
export DOCKER_HOST=tcp://localhost:4243

4)重啟docker服務
[root@docker-server ~]# systemctl daemon-reload
[root@docker-server ~]# systemctl restart docker

5)檢查發現4243埠已啟動
[root@docker-server ~]# netstat -ant
.......
tcp6       0      0 :::4243                 :::*                    LISTEN     
[root@docker-server ~]# lsof -i:4243
COMMAND     PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
dockerd-c 15400 root    6u  IPv6  59175      0t0  TCP *:4243 (LISTEN)

2)報錯二
ERROR: Service '****' failed to build: shim error: docker-runc not installed on system

解決辦法

[root@docker-server ~]# cd /usr/libexec/docker/
[root@docker-server ~]# ll
total 7384
-rwxr-xr-x 1 root root  820472 Mar  8 01:07 docker-init-current
-rwxr-xr-x 1 root root 1687304 Mar  8 01:07 docker-proxy-current
-rwxr-xr-x 1 root root 5047808 Mar  8 01:07 docker-runc-current
[root@docker-server ~]# ln -s docker-runc-current docker-runc
[root@docker-server ~]# ll
total 7384
-rwxr-xr-x 1 root root  820472 Mar  8 01:07 docker-init-current
-rwxr-xr-x 1 root root 1687304 Mar  8 01:07 docker-proxy-current
lrwxrwxrwx 1 root root      19 May 12 01:07 docker-runc -> docker-runc-current
-rwxr-xr-x 1 root root 5047808 Mar  8 01:07 docker-runc-current

3)報錯三:docker官方映象無法訪問問題,訪問超時!

在配置docker穩定儲存庫時,發現網路超時!
[root@workbench-test ~]# yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
Loaded plugins: fastestmirror
adding repo from: https://download.docker.com/linux/centos/docker-ce.repo
grabbing file https://download.docker.com/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
Could not fetch/save url https://download.docker.com/linux/centos/docker-ce.repo to file /etc/yum.repos.d/docker-ce.repo: [Errno 12] Timeout on 
https://download.docker.com/linux/centos/docker-ce.repo: (28, 'Operation timed out after 30001 milliseconds with 0 out of 0 bytes received')

或者使用"yum install docker-ce"安裝的時候,也是報錯:
https://download.docker.com/linux/centos/7/x86_64/stable/repodata/repomd.xml: [Errno 12] Timeout on https://download.docker.com/linux/centos/7/
x86_64/stable/repodata/repomd.xml: (28, 'Operation timed out after 30001 milliseconds with 0 out of 0 bytes received')

解決辦法:
由於國內訪問不到docker官方映象的緣故,可以通過aliyun的源來完成!
[root@workbench-test ~]# yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

再次配置docker文件儲存庫就OK了
[root@workbench-test ~]# yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
Loaded plugins: fastestmirror
adding repo from: https://download.docker.com/linux/centos/docker-ce.repo
grabbing file https://download.docker.com/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo

再次安裝docker-ce就可以了
[root@workbench-test ~]# yum install docker-ce

4)報錯ImportError: No module named 'requests.packages.urllib3'

解決辦法:安裝 Requests
[root@workbench-test ~]# git clone git://github.com/kennethreitz/requests.git
[root@workbench-test ~]# cd requests
[root@workbench-test ~]# pip install .

5)報錯:ImportError: cannot import name UnrewindableBodyError

解決辦法:重灌 urllib3 庫
[root@workbench-test ~]# pip uninstall urllib3
[root@workbench-test ~]# pip install --upgrade urllib3

相關文章