2017-05-07 752 views
2

docker build命令没有构建我试图创建的docker机器。我在网上搜索,我找不到答案。以下是我的dockerfile。我认为问题始于取http://dl-cdn.alpinelinux.org/alpine/v3.4/main/x86_64/APKINDEX.tar.gz命令'/ bin/sh -c apk add ...返回一个非零代码:6

FROM python:3.5-alpine 
MAINTAINER ******* <[email protected]******.com> 


ENV INSTALL_PATH /web 
RUN mkdir -p ${INSTALL_PATH} 
COPY . ${INSTALL_PATH} 
WORKDIR ${INSTALL_PATH} 

RUN apk add --no-cache --virtual .build-deps build-base libffi-dev postgresql-dev uwsgi-python supervisor \ 
     && pip install --trusted-host github.com --process-dependency-links -e . \ 
     && find /usr/local \(-type d -a -name test -o -name tests \) \ 
      -o \(-type f -a -name '*.pyc' -o -name '*.pyo' \) -exec rm -rf '{}' + \ 
     && runDeps="$(scanelf --needed --nobanner --recursive /usr/local \ 
      | awk '{ gsub(/,/, "\nso:", $2); print "so:" $2 }' \ 
      | sort -u | xargs -r apk info --installed | sort -u \ 
     )" \ 
     && apk add --virtual .rundeps $runDeps && apk del .build-deps 

的输出如下:

Sending build context to Docker daemon 11.26kB 
Step 1/7 : FROM python:3.5-alpine 
---> 9691bd606b6d 
Step 2/7 : MAINTAINER ******* <[email protected]*******.com> 
---> Using cache 
---> 71df6ccd567e 
Step 3/7 : ENV INSTALL_PATH /web 
---> Using cache 
---> 06ced81d3941 
Step 4/7 : RUN mkdir -p ${INSTALL_PATH} 
---> Using cache 
---> ad857704376d 
Step 5/7 : COPY . ${INSTALL_PATH} 
---> Using cache 
---> c6ddc57309a2 
Step 6/7 : WORKDIR ${INSTALL_PATH} 
---> Using cache 
---> 62f0dbfaa3eb 
Step 7/7 : RUN apk add --no-cache --virtual .build-deps build-base libffi-dev postgresql-dev uwsgi-python supervisor   && pip install --trusted-host github.com --process-dependency-links -e .   && find /usr/local \(-type d -a -name test -o -name tests \)   -o \(-type f -a -name '*.pyc' -o -name '*.pyo' \) -exec rm -rf '{}' +   && runDeps="$(scanelf --needed --nobanner --recursive /usr/local   | awk '{ gsub(/,/, "\nso:", $2); print "so:" $2 }'   | sort -u | xargs -r apk info --installed | sort -u  )"   && apk add --virtual .rundeps $runDeps && apk del .build-deps 
---> Running in 1abedb8ada2a 
fetch http://dl-cdn.alpinelinux.org/alpine/v3.4/main/x86_64/APKINDEX.tar.gz 
WARNING: Ignoring http://dl-cdn.alpinelinux.org/alpine/v3.4/main/x86_64/APKINDEX.tar.gz: temporary error (try again later) 
fetch http://dl-cdn.alpinelinux.org/alpine/v3.4/community/x86_64/APKINDEX.tar.gz 
WARNING: Ignoring http://dl-cdn.alpinelinux.org/alpine/v3.4/community/x86_64/APKINDEX.tar.gz: temporary error (try again later) 
ERROR: unsatisfiable constraints: 
    .build-deps-0: 
    masked in: cache 
    satisfies: world[.build-deps] 
    build-base (missing): 
    required by: 
    libffi-dev (missing): 
    required by: 
    postgresql-dev (missing): 
    required by: 
    uwsgi-python (missing): 
    required by: 
    supervisor (missing): 
    required by: 
The command '/bin/sh -c apk add --no-cache --virtual .build-deps build-base libffi-dev postgresql-dev uwsgi-python supervisor   && pip install --trusted-host github.com --process-dependency-links -e .   && find /usr/local \(-type d -a -name test -o -name tests \)   -o \(-type f -a -name '*.pyc' -o -name '*.pyo' \) -exec rm -rf '{}' +   && runDeps="$(scanelf --needed --nobanner --recursive /usr/local   | awk '{ gsub(/,/, "\nso:", $2); print "so:" $2 }'   | sort -u | xargs -r apk info --installed | sort -u  )"   && apk add --virtual .rundeps $runDeps && apk del .build-deps' returned a non-zero code: 6 

回答

1

分隔每个命令,看看哪些是准确导致的问题。而不是连续使用& &连接。使用apk add的RUN命令仅对一个包装,然后以同样的方式进行。

以这种方式,你会看到他们中的哪一个确实导致了问题。

这只适用于“调试”。解决问题后,您可以将它们全部再次密封。

+0

我明白你的想法,很棒。但是,如果您检查了,则在运行apk添加部分失败,其中包括构建图像,这是使用泊坞窗时要完成的第一步。我在寻找的是能够给我提示如何解决这个问题的人。谢谢 –

+1

但是你可以将你的第一个命令从安装libffi-dev postgresql-dev uwsgi-python监督器中分离出来,每个命令都在一个RUN apk命令中。做到这一点,看看他们究竟是哪一个给你带来麻烦 – OscarAkaElvis

相关问题