为什么这个容器不能正常运行?

时间:2020-06-16 16:23:34

标签: python docker dockerfile

我正在尝试在Docker上运行容器,并且收到以下错误消息:

Successfully built 9df8ac137547
Successfully tagged ex-build-dev:latest
$ build-dev % docker container run -it -v "$(pwd):/app" -p 80:8000 --name python-server ex-build-dev
docker: Error response from daemon: OCI runtime create failed: container_linux.go:349: starting container process caused "exec: \"usr/local/bin/python\": stat usr/local/bin/python: no such file or directory": unknown.

这是我用来构建映像的Dockerfile:

FROM python:3.6
LABEL maintainer 'Martin'

RUN useradd www && \
    mkdir /app && \
    mkdir /log && \
    chown www /log

USER www
VOLUME /log
WORKDIR /app
EXPOSE 8000

ENTRYPOINT ["usr/local/bin/python"]
CMD ["run.py"]

有人知道ENTRYPOINT被识别吗?

1 个答案:

答案 0 :(得分:1)

您将WORKDIR /appENTRYPOINT ["usr/local/bin/python"]一起使用,并且最终执行:

/app/usr/local/bin/python

代替:

/usr/local/bin/python

在您的情况下,为ENTRYPOINT指令添加绝对路径:/usr/local/bin/python