我的问题

我的问题

我最近将我的 docker 镜像切换到 Alpine Linux,而 Alpine 目前没有 uwsgi-python3 插件。因此,我在容器构建过程中使用 编译 uwsgi pip3 install uwsgi

由于某种原因,这个操作时不时会失败,没有任何明显的规律。我只是在一个最小的 Dockerfile 上重复了这个操作:

FROM alpine:3.4

RUN apk add --no-cache \
    gcc \
    linux-headers \
    musl-dev \
    python3 \
    python3-dev

RUN pip3 install --upgrade pip setuptools

RUN pip3 install uwsgi

当我运行的时候docker build --no-cache .,有时这个 Dockerfile 可以正常构建:

$ docker build --no-cache .
Sending build context to Docker daemon 2.048 kB
Step 1 : FROM alpine:3.4
 ---> 4e38e38c8ce0
Step 2 : RUN apk add --no-cache     gcc     linux-headers   musl-dev    python3     python3-dev
 ---> Running in 8667f0d6c970
fetch http://dl-cdn.alpinelinux.org/alpine/v3.4/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.4/community/x86_64/APKINDEX.tar.gz
(1/27) Installing binutils-libs (2.26-r0)
(2/27) Installing binutils (2.26-r0)
(3/27) Installing gmp (6.1.0-r0)
(4/27) Installing isl (0.14.1-r0)
(5/27) Installing libgomp (5.3.0-r0)
(6/27) Installing libatomic (5.3.0-r0)
(7/27) Installing libgcc (5.3.0-r0)
(8/27) Installing pkgconf (0.9.12-r0)
(9/27) Installing pkgconfig (0.25-r1)
(10/27) Installing mpfr3 (3.1.2-r0)
(11/27) Installing mpc1 (1.0.3-r0)
(12/27) Installing libstdc++ (5.3.0-r0)
(13/27) Installing gcc (5.3.0-r0)
(14/27) Installing linux-headers (4.4.6-r1)
(15/27) Installing musl-dev (1.1.14-r10)
(16/27) Installing libbz2 (1.0.6-r4)
(17/27) Installing expat (2.1.1-r1)
(18/27) Installing libffi (3.2.1-r2)
(19/27) Installing gdbm (1.11-r1)
(20/27) Installing xz-libs (5.2.2-r1)
(21/27) Installing ncurses-terminfo-base (6.0-r7)
(22/27) Installing ncurses-terminfo (6.0-r7)
(23/27) Installing ncurses-libs (6.0-r7)
(24/27) Installing readline (6.3.008-r4)
(25/27) Installing sqlite-libs (3.13.0-r0)
(26/27) Installing python3 (3.5.1-r3)
(27/27) Installing python3-dev (3.5.1-r3)
Executing busybox-1.24.2-r9.trigger
OK: 175 MiB in 38 packages
 ---> 7ccbdeeab3ae
Removing intermediate container 8667f0d6c970
Step 3 : RUN pip3 install --upgrade pip setuptools
 ---> Running in 319ca3341483
Collecting pip
  Downloading pip-8.1.2-py2.py3-none-any.whl (1.2MB)
Collecting setuptools
  Downloading setuptools-24.0.3-py2.py3-none-any.whl (441kB)
Installing collected packages: pip, setuptools
  Found existing installation: pip 7.1.2
    Uninstalling pip-7.1.2:
      Successfully uninstalled pip-7.1.2
  Found existing installation: setuptools 18.2
    Uninstalling setuptools-18.2:
      Successfully uninstalled setuptools-18.2
Successfully installed pip-8.1.2 setuptools-24.0.3
 ---> 01bd82afce3d
Removing intermediate container 319ca3341483
Step 4 : RUN pip3 install uwsgi
 ---> Running in 6ca045b9c833
Collecting uwsgi
  Downloading uwsgi-2.0.13.1.tar.gz (784kB)
Installing collected packages: uwsgi
  Running setup.py install for uwsgi: started
    Running setup.py install for uwsgi: finished with status 'done'
Successfully installed uwsgi-2.0.13.1
 ---> 7c46cf5ed333
Removing intermediate container 6ca045b9c833
Successfully built 7c46cf5ed333

有时也不是:

$ docker build --no-cache .
Sending build context to Docker daemon 2.048 kB
Step 1 : FROM alpine:3.4
 ---> 4e38e38c8ce0
Step 2 : RUN apk add --no-cache     gcc     linux-headers   musl-dev    python3     python3-dev
 ---> Running in 264d32d8d765
fetch http://dl-cdn.alpinelinux.org/alpine/v3.4/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.4/community/x86_64/APKINDEX.tar.gz
(1/27) Installing binutils-libs (2.26-r0)
(2/27) Installing binutils (2.26-r0)
(3/27) Installing gmp (6.1.0-r0)
(4/27) Installing isl (0.14.1-r0)
(5/27) Installing libgomp (5.3.0-r0)
(6/27) Installing libatomic (5.3.0-r0)
(7/27) Installing libgcc (5.3.0-r0)
(8/27) Installing pkgconf (0.9.12-r0)
(9/27) Installing pkgconfig (0.25-r1)
(10/27) Installing mpfr3 (3.1.2-r0)
(11/27) Installing mpc1 (1.0.3-r0)
(12/27) Installing libstdc++ (5.3.0-r0)
(13/27) Installing gcc (5.3.0-r0)
(14/27) Installing linux-headers (4.4.6-r1)
(15/27) Installing musl-dev (1.1.14-r10)
(16/27) Installing libbz2 (1.0.6-r4)
(17/27) Installing expat (2.1.1-r1)
(18/27) Installing libffi (3.2.1-r2)
(19/27) Installing gdbm (1.11-r1)
(20/27) Installing xz-libs (5.2.2-r1)
(21/27) Installing ncurses-terminfo-base (6.0-r7)
(22/27) Installing ncurses-terminfo (6.0-r7)
(23/27) Installing ncurses-libs (6.0-r7)
(24/27) Installing readline (6.3.008-r4)
(25/27) Installing sqlite-libs (3.13.0-r0)
(26/27) Installing python3 (3.5.1-r3)
(27/27) Installing python3-dev (3.5.1-r3)
Executing busybox-1.24.2-r9.trigger
OK: 175 MiB in 38 packages
 ---> b7d316f0ff9d
Removing intermediate container 264d32d8d765
Step 3 : RUN pip3 install --upgrade pip setuptools
 ---> Running in beba565f5d1c
Collecting pip
  Downloading pip-8.1.2-py2.py3-none-any.whl (1.2MB)
Collecting setuptools
  Downloading setuptools-24.0.3-py2.py3-none-any.whl (441kB)
Installing collected packages: pip, setuptools
  Found existing installation: pip 7.1.2
    Uninstalling pip-7.1.2:
      Successfully uninstalled pip-7.1.2
  Found existing installation: setuptools 18.2
    Uninstalling setuptools-18.2:
      Successfully uninstalled setuptools-18.2
Successfully installed pip-8.1.2 setuptools-24.0.3
 ---> 9402ed04a075
Removing intermediate container beba565f5d1c
Step 4 : RUN pip3 install uwsgi
 ---> Running in ba0b8d67469d
Collecting uwsgi
  Downloading uwsgi-2.0.13.1.tar.gz (784kB)
Installing collected packages: uwsgi
  Running setup.py install for uwsgi: started
    Running setup.py install for uwsgi: finished with status 'error'
    Complete output from command /usr/bin/python3.5 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-8te7tuuc/uwsgi/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-9e91dasm-record/install-record.txt --single-version-externally-managed --compile:
    running install
    using profile: buildconf/default.ini
    detected include path: ['/usr/include', '/usr/lib/gcc/x86_64-alpine-linux-musl/5.3.0/include']
    Patching "bin_name" to properly install_scripts dir
    detected CPU cores: 2
    configured CFLAGS: -O2 -I. -Wall -Werror -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -DUWSGI_HAS_IFADDRS -DUWSGI_LOCK_USE_MUTEX -DUWSGI_EVENT_USE_EPOLL -DUWSGI_EVENT_TIMER_USE_TIMERFD -DUWSGI_EVENT_FILEMONITOR_USE_INOTIFY -DUWSGI_VERSION="\"2.0.13.1\"" -DUWSGI_VERSION_BASE="2" -DUWSGI_VERSION_MAJOR="0" -DUWSGI_VERSION_MINOR="13" -DUWSGI_VERSION_REVISION="1" -DUWSGI_VERSION_CUSTOM="\"\"" -DUWSGI_YAML -DUWSGI_PLUGIN_DIR="\".\"" -DUWSGI_DECLARE_EMBEDDED_PLUGINS="UDEP(python);UDEP(gevent);UDEP(ping);UDEP(cache);UDEP(nagios);UDEP(rrdtool);UDEP(carbon);UDEP(rpc);UDEP(corerouter);UDEP(fastrouter);UDEP(http);UDEP(signal);UDEP(syslog);UDEP(rsyslog);UDEP(logsocket);UDEP(router_uwsgi);UDEP(router_redirect);UDEP(router_basicauth);UDEP(zergpool);UDEP(redislog);UDEP(mongodblog);UDEP(router_rewrite);UDEP(router_http);UDEP(logfile);UDEP(router_cache);UDEP(rawrouter);UDEP(router_static);UDEP(sslrouter);UDEP(spooler);UDEP(cheaper_busyness);UDEP(symcall);UDEP(transformation_tofile);UDEP(transformation_gzip);UDEP(transformation_chunked);UDEP(transformation_offload);UDEP(router_memcached);UDEP(router_redis);UDEP(router_hash);UDEP(router_expires);UDEP(router_metrics);UDEP(transformation_template);UDEP(stats_pusher_socket);" -DUWSGI_LOAD_EMBEDDED_PLUGINS="ULEP(python);ULEP(gevent);ULEP(ping);ULEP(cache);ULEP(nagios);ULEP(rrdtool);ULEP(carbon);ULEP(rpc);ULEP(corerouter);ULEP(fastrouter);ULEP(http);ULEP(signal);ULEP(syslog);ULEP(rsyslog);ULEP(logsocket);ULEP(router_uwsgi);ULEP(router_redirect);ULEP(router_basicauth);ULEP(zergpool);ULEP(redislog);ULEP(mongodblog);ULEP(router_rewrite);ULEP(router_http);ULEP(logfile);ULEP(router_cache);ULEP(rawrouter);ULEP(router_static);ULEP(sslrouter);ULEP(spooler);ULEP(cheaper_busyness);ULEP(symcall);ULEP(transformation_tofile);ULEP(transformation_gzip);ULEP(transformation_chunked);ULEP(transformation_offload);ULEP(router_memcached);ULEP(router_redis);ULEP(router_hash);ULEP(router_expires);ULEP(router_metrics);ULEP(transformation_template);ULEP(stats_pusher_socket);"
    *** uWSGI compiling server core ***
    [thread 1][gcc] core/utils.o
    [thread 0][gcc] core/protocol.o
    [thread 0][gcc] core/socket.o
    [thread 0][gcc] core/logging.o
    [thread 1][gcc] core/master.o
    [thread 0][gcc] core/master_utils.o
    [thread 1][gcc] core/emperor.o
    [thread 0][gcc] core/notify.o
    [thread 0][gcc] core/mule.o
    [thread 0][gcc] core/subscription.o
    [thread 1][gcc] core/stats.o
    [thread 1][gcc] core/sendfile.o
    [thread 0][gcc] core/async.o
    [thread 1][gcc] core/master_checks.o
    [thread 0][gcc] core/fifo.o
    [thread 1][gcc] core/offload.o
    [thread 0][gcc] core/io.o
    [thread 1][gcc] core/static.o
    [thread 1][gcc] core/websockets.o
    [thread 0][gcc] core/spooler.o
    [thread 1][gcc] core/snmp.o
    [thread 1][gcc] core/exceptions.o
    [thread 0][gcc] core/config.o
    [thread 1][gcc] core/setup_utils.o
    [thread 1][gcc] core/clock.o
    [thread 0][gcc] core/init.o
    [thread 1][gcc] core/buffer.o
    [thread 0][gcc] core/reader.o
    [thread 1][gcc] core/writer.o
    [thread 0][gcc] core/alarm.o
    [thread 1][gcc] core/cron.o
    [thread 0][gcc] core/hooks.o
    [thread 1][gcc] core/plugins.o
    [thread 1][gcc] core/lock.o
    [thread 0][gcc] core/cache.o
    [thread 1][gcc] core/daemons.o
    [thread 1][gcc] core/errors.o
    [thread 1][gcc] core/hash.o
    [thread 1][gcc] core/master_events.o
    [thread 1][gcc] core/chunked.o
    [thread 0][gcc] core/queue.o
    [thread 1][gcc] core/event.o
    [thread 0][gcc] core/signal.o
    [thread 1][gcc] core/strings.o
    [thread 0][gcc] core/progress.o
    [thread 1][gcc] core/timebomb.o
    [thread 0][gcc] core/ini.o
    [thread 1][gcc] core/fsmon.o
    [thread 0][gcc] core/mount.o
    [thread 1][gcc] core/metrics.o
    [thread 0][gcc] core/plugins_builder.o
    [thread 0][gcc] core/sharedarea.o
    [thread 0][gcc] core/rpc.o
    [thread 1][gcc] core/gateway.o
    [thread 0][gcc] core/loop.o
    [thread 1][gcc] core/cookie.o
    [thread 0][gcc] core/querystring.o
    [thread 1][gcc] core/rb_timers.o
    [thread 0][gcc] core/transformations.o
    [thread 0][gcc] core/uwsgi.o
    [thread 1][gcc] proto/base.o
    [thread 1][gcc] proto/uwsgi.o
    [thread 1][gcc] proto/http.o
    [thread 1][gcc] proto/fastcgi.o
    [thread 1][gcc] proto/scgi.o
    [thread 1][gcc] proto/puwsgi.o
    [thread 1][gcc] lib/linux_ns.o
    [thread 1][gcc] core/yaml.o
    [thread 1][gcc] core/dot_h.o

    ----------------------------------------
Command "/usr/bin/python3.5 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-8te7tuuc/uwsgi/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-9e91dasm-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-8te7tuuc/uwsgi/
The command '/bin/sh -c pip3 install uwsgi' returned a non-zero code: 1

我在最新的 OS X 上运行最新的 Docker:

$ docker -v
Docker version 1.12.0-rc4, build e4a0dbc, experimental
$ uname -a
Darwin daedra.xxx.com 15.5.0 Darwin Kernel Version 15.5.0: Tue Apr 19 18:36:36 PDT 2016; root:xnu-3248.50.21~8/RELEASE_X86_64 x86_64 i386 MacBookPro12,1 Darwin

在docker化的Alpine Linux内部:

# uname -a
Linux 738b7cb0ae0b 4.4.15-moby #1 SMP Tue Jul 12 14:03:08 UTC 2016 x86_64 Linux

更新这刚刚发生在 Ubuntu 上(作为 Docker 主机):

...
    [thread 0][gcc] core/yaml.o
    [thread 3][gcc] core/ssl.o
    gcc: error trying to exec 'cc1': execvp: No such file or directory

    ----------------------------------------
Command "/usr/bin/python3.5 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-kwwje2x6/uwsgi/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-jb3jm_1x-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-kwwje2x6/uwsgi/
remote: The command '/bin/sh -c pip3 install --no-cache-dir --disable-pip-version-check uwsgi' returned a non-zero code: 1

第二次运行,编译正常!

我的问题

我可以做些什么来使这个 Dockerfile 持续构建(或失败)而不是随机失败?

答案1

运行 CFLAGS="$CFLAGS -L/lib" pip3 安装 uwsgi

在类似环境中一致运行

其他方法:

你有没有尝试过

-e git://github.com/unbit/uwsgi/archive/uwsgi-2.0.zip#egg=uwsgi

在您的 requirements.txt 中?

你需要pcre-dev安装该包

相关内容