问题描述
尝试遵循一些[ 1 ] [ 2 ]通过AWS am进行的简单Docker教程,并收到以下错误:
Trying to follow a few[1][2] simple Docker tutorials via AWS am and getting the following error:
> 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: 127
Dockerfile:
Dockerfile:
# For Python 3.4
FROM amazon/aws-eb-python:3.4.2-onbuild-3.5.1
哪个点返回以下内容:
> which pip
./bin/pip
相关文件结构:
.
├── Dockerfile
├── bin
│ ├── activate
│ ├── pip
│ ├── pip3
│ ├── pip3.5
│ ├── python -> python3
│ ├── python-config
│ ├── python3
│ ├── python3.5 -> python3
│ .
.
同样,对于所有Docker来说都是菜鸟,所以我不确定要采取什么故障排除步骤.请让我知道我还能提供什么其他有用的信息.
Again, noob in all things Docker so I'm not sure what troubleshooting steps to take. Please let me know what other helpful information I can provide.
推荐答案
这里有些奇怪.为什么在Dockerfile旁边有virtualenv内容?您正在从中构建的图像在/var/app上为您创建virtualenv(在容器中,是吗?).我相信ONBUILD命令会复制它(或其中的一部分)并破坏其余的过程,从而使/var/app/bin/pip无法操作.
Something is very odd here. Why do you have the virtualenv content next to your Dockerfile?The image you are building from creates the virtualenv on /var/app (within the container, yes?) for you.I believe that the ONBUILD command copies it (or parts of it) over and corrupt the rest of the process, making the /var/app/bin/pip inoperable.
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",即可将其复制到容器中(否则,如果没有,它将跳过).
You should not care about externally having /var/app available on the host. You just need (based on the Dockerbuild file) have the "requirements.txt" available on the host, to be copied into the container (or not, if not, it will skip).
这篇关于Docker Build找不到点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!