尝试通过AWS am遵循一些[1][2]简单的Docker教程,得到以下错误:
> docker build -t my-app-image .
Sending build context to Docker daemon 94.49 MB
Step 1 : FROM amazon/aws-eb-python:3.4.2-onbuild-3.5.1
# Executing 2 build triggers...
Step 1 : ADD . /var/app
---> Using cache
Step 1 : RUN if [ -f /var/app/requirements.txt ]; then /var/app/bin/pip install -r /var/app/requirements.txt; fi
---> Running in d48860787e63
/bin/sh: 1: /var/app/bin/pip: not found
The command '/bin/sh -c if [ -f /var/app/requirements.txt ]; then /var/app/bin/pip install -r /var/app/requirements.txt; fi' returned a non-zero code: 127Dockerfile:
# For Python 3.4
FROM amazon/aws-eb-python:3.4.2-onbuild-3.5.1其中pip返回以下内容:
> which pip
./bin/pip相关文件结构:
.
├── Dockerfile
├── bin
│ ├── activate
│ ├── pip
│ ├── pip3
│ ├── pip3.5
│ ├── python -> python3
│ ├── python-config
│ ├── python3
│ ├── python3.5 -> python3
│ .
.再说一次,在所有的Docker中都是菜鸟,所以我不确定应该采取什么故障排除步骤。请让我知道我还能提供什么有用的信息。
发布于 2016-08-28 21:24:27
这里有些东西很奇怪。为什么您的Dockerfile文件旁边有virtualenv内容?The image you are building from在/var/app上创建virtualenv (在容器中,是吗?)为了你。我相信ONBUILD命令会复制它(或其中的一部分)并破坏进程的其余部分,从而使/var/app/bin/pip无法运行。
FROM python:3.4.2 <-- this is the base image, on top of which the following command will be applied
WORKDIR /var/app <-- this is the working dir (a la 'cd /var/app')
RUN pip3 install virtualenv <-- using pip3 (installed using base image I presume) to install the virtualenv package
RUN virtualenv /var/app <-- creating a virtual env on /var/app
RUN /var/app/bin/pip install --download-cache /src uwsgi <-- using the recently install virtualenv pip to install uwsgi
...
ONBUILD ADD . /var/app <-- add the contents of the directory where the Dockerfile is built from, I think this is where the corruption happen
ONBUILD RUN if [ -f /var/app/requirements.txt ]; then /var/app/bin/pip install -r /var/app/requirements.txt; fi <-- /var/app/bin/pip has beed corrupted您不应该关心在主机上外部是否有/var/app可用。您只需要(基于Dockerbuild文件)将主机上可用的"requirements.txt“复制到容器中(否则,它将跳过)。
发布于 2016-08-25 14:50:31
/var/app/bin/pip被禁止工作,因为amazon/aws-eb-python:3.4.2-onbuild-3.5.1 Dockerfile包括:
RUN pip3 install virtualenv
RUN virtualenv /var/app
RUN /var/app/bin/pip install --download-cache /src uwsgi这意味着当你使用这个镜像作为基础镜像时,它的两个ONBUILD instructions将应用于你当前的构建。
ONBUILD ADD . /var/app
ONBUILD RUN if [ -f /var/app/requirements.txt ]; then /var/app/bin/pip install -r /var/app/requirements.txt; fi尝试使用一个更简单的Dockerfile,并从它打开一个shell会话,以检查/var/app是否在那里,以及pip是否正确安装。
您还可以直接测试重新构建3.4.2-aws-eb-onbuild映像本身,这也是为了测试。
发布于 2016-08-25 15:29:49
我认为问题在于您是如何组织bin/pip文件的
来自Docker文档:https://docs.docker.com/engine/reference/builder/#add
If <dest> does not end with a trailing slash, it will be considered a regular file and the contents of <src> will be written at <dest>.所以你的文件结构应该是:
.
├── Dockerfile
├── app
| |__bin
| | |
│ ├── activate
│ ├── pip
│ ├── pip3
│ ├── pip3.5
│ ├── python -> python3
│ ├── python-config
│ ├── python3
│ ├── python3.5 -> python3
│ .
.https://stackoverflow.com/questions/39085599
复制相似问题