我在Docker(RHEL7)上使用python构建新映像存在问题。
我使用此代码使用Dockerfile构建器创建映像:
docker build -t navitia-builder .
出现以下错误:
Command "/usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build-uSw6UQ/cffi/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-FjGJow-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-uSw6UQ/cffi
You are using pip version 7.1.2, however version 8.1.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
但我已经安装了pip版本8.1.2并为我的图像安装了要求:
docker-compose==1.2.0
docker-py==1.1.0
pytest==2.7.1
requests==2.5.3
fabric==1.10.2
jinja2==2.8
nose==1.3.7
我还升级了setuptools。
这是我的Dockerfile
FROM gliderlabs/alpine:3.3
WORKDIR /usr/local/navitia
RUN apk add --update \
alpine-sdk \
libffi-dev
python \
python-dev \
py-pip \
docker \
&& rm -rf /var/cache/apk/*
RUN pip install --upgrade pip
# Install openrc - see: https://github.com/gliderlabs/docker-alpine/issues/42
RUN apk update && apk add openrc &&\
# Tell openrc its running inside a container, till now that has meant LXC
sed -i 's/#rc_sys=""/rc_sys="lxc"/g' /etc/rc.conf &&\
# Tell openrc loopback and net are already there, since docker handles the networking
echo 'rc_provide="loopback net"' >> /etc/rc.conf &&\
# no need for loggers
sed -i 's/^#\(rc_logger="YES"\)$/\1/' /etc/rc.conf &&\
# can't get ttys unless you run the container in privileged mode
sed -i '/tty/d' /etc/inittab &&\
# can't set hostname since docker sets it
sed -i 's/hostname $opts/# hostname $opts/g' /etc/init.d/hostname &&\
# can't mount tmpfs since not privileged
sed -i 's/mount -t tmpfs/# mount -t tmpfs/g' /lib/rc/sh/init.sh &&\
# can't do cgroups
sed -i 's/cgroup_add_service /# cgroup_add_service /g' /lib/rc/sh/openrc-run.sh
COPY ./requirements.txt /usr/local/navitia/docker_navitia/requirements.txt
RUN pip install -r /usr/local/navitia/docker_navitia/requirements.txt
RUN git clone https://github.com/CanalTP/fabric_navitia.git /usr/local/navitia/fabric_navitia
RUN pip install -r /usr/local/navitia/fabric_navitia/requirements.txt
ENV PYTHONPATH /usr/local/navitia:/usr/local/navitia/docker_navitia:/usr/local/navitia/fabric_navitia:/usr/bin/python
# RUN echo -e '#!/bin/bash\n/sbin/init && service docker start' > /usr/local/navitia/entrypoint.sh && chmod +x /usr/local/navitia/entrypoint.sh
COPY . /usr/local/navitia/docker_navitia
WORKDIR /usr/local/navitia/docker_navitia
ENTRYPOINT ["/sbin/init"]
现在我需要你,因为我没有更多的想法。