简体   繁体   English

docker:来自守护程序的错误响应:OCI 运行时创建失败:

[英]docker: Error response from daemon: OCI runtime create failed:

I am trying to run my docker image, but I am receiving the following error:我正在尝试运行我的 docker 映像,但收到以下错误:

docker: Error response from daemon: OCI runtime create failed: container_linux.go:349: starting container process caused "exec: \"python3\": executable file not found in $PATH": unknown.
ERRO[0000] error waiting for container: context canceled

Here is my Dockerfile:这是我的 Dockerfile:

FROM python:3.6-alpine3.7

RUN apk add --no-cache python3-dev \
    && pip3 install --upgrade pip

RUN apk add --no-cache --update \
    python3 python3-dev gcc \
    gfortran musl-dev

RUN apk add --no-cache libressl-dev musl-dev libffi-dev

RUN python3.6 -m pip install --upgrade pip

RUN apk --no-cache add git

RUN apk add mariadb-dev

WORKDIR /socialworks-api

COPY . /socialworks-api

RUN pip3 --no-cache-dir install -r requirements.txt

ENV PATH="/opt/gtk/bin:$env/development.env"

EXPOSE 5000

ENTRYPOINT ["python3"]
CMD ["app.py"]

I think the issue might be with the ENV PATH which I set.我认为问题可能出在我设置的 ENV PATH 上。 I have also tried setting it to:我也尝试将其设置为:

ENV PATH="/opt/gtk/bin:${env/development.env}"

But I would receive the following error when building my dockerfile:但是在构建我的 dockerfile 时会收到以下错误:

Step 11/14 : ENV PATH="/opt/gtk/bin:${env/development.env}"
failed to process "\"/opt/gtk/bin:${env/development.env}\"": missing ':' in substitution

Without setting the environment, my application won't run.如果不设置环境,我的应用程序将无法运行。

I have also tried running on my dockerfile this command:我也试过在我的 dockerfile 上运行这个命令:

RUN export $(grep -v '^#' ./env/development.env | xargs)

It build successfully, but when I enter this command to the terminal:它构建成功,但是当我在终端输入这个命令时:

docker run -it flaskapp docker 运行-it flaskapp

I am receiving an error that it still unable to locate the env variables.我收到一个错误,它仍然无法找到环境变量。

$ docker run -it flaskapp
Traceback (most recent call last):
  File "app.py", line 11, in <module>
    app.config.from_object("config.Config")
  File "/usr/local/lib/python3.6/site-packages/flask/config.py", line 174, in from_object
    obj = import_string(obj)
  File "/usr/local/lib/python3.6/site-packages/werkzeug/utils.py", line 568, in import_string
    __import__(import_name)
  File "/socialworks-api/config.py", line 4, in <module>
    class Config(object):
  File "/socialworks-api/config.py", line 5, in Config
    MYSQL_HOST = os.environ['MYSQL_HOST']
  File "/usr/local/lib/python3.6/os.py", line 669, in __getitem__
    raise KeyError(key) from None
KeyError: 'MYSQL_HOST'

In your Dockerfile you specify在您指定的 Dockerfile

ENV PATH="/opt/gtk/bin:$env/development.env"

When you later run python3 , the system looks in only these two directories, and when there's not a Python there, you get the error you see.当您稍后运行python3时,系统查看这两个目录,当那里没有 Python 时,您会看到您看到的错误。 It's probably in /usr/bin/python3 , but the directory /usr/bin isn't in $PATH .它可能在/usr/bin/python3中,但目录/usr/bin不在$PATH中。

The simplest answer here is to delete this line entirely.这里最简单的答案是完全删除这一行。 Your Dockerfile creates neither a /opt/gtk nor a /development.env directory, so there's no files in either path that could be executed.您的 Dockerfile 既不创建/opt/gtk也不创建/development.env目录,因此在任一路径中都没有可以执行的文件。 If you do need to install custom software, putting it in a directory that's in the default system path (like /usr/local/bin ) is a good approach.如果您确实需要安装自定义软件,将其放在默认系统路径(如/usr/local/bin )中的目录中是一个好方法。

If you do need to keep this line, make sure the existing $PATH stays as part of the value.如果确实需要保留此行,请确保现有的$PATH保留为值的一部分。

ENV PATH="/opt/gtk/bin:$PATH"

(Don't specify ENTRYPOINT ["python"] ; combine this into a single CMD ["python3", "app.py"] . I'd encourage you to run docker run --rm -it yourimage /bin/sh to look around the filesystem and run debugging commands like env , but the ENTRYPOINT declaration breaks this use, and having the script file named in the CMD means it's still not the "container-as-command" pattern.) (不要指定ENTRYPOINT ["python"] ;将其组合成一个CMD ["python3", "app.py"] 。我鼓励您运行docker run --rm -it yourimage /bin/sh到查看文件系统并运行诸如env之类的调试命令,但是ENTRYPOINT声明破坏了这种使用,并且在CMD中命名的脚本文件意味着它仍然不是“container-as-command”模式。)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 来自守护程序的Docker错误响应:OCI运行时创建失败 - Docker Error response from daemon: OCI runtime create failed 如何解决“docker:来自守护进程的错误响应:OCI 运行时创建失败:无法检索 OCI 运行时错误” - How to solve "docker: Error response from daemon: OCI runtime create failed: unable to retrieve OCI runtime error" docker:来自守护进程的错误响应:OCI 运行时创建失败:无法检索 OCI 运行时错误 - docker: Error response from daemon: OCI runtime create failed: unable to retrieve OCI runtime error docker:来自守护进程的错误响应:未能创建 shim 任务:OCI 运行时创建失败:runc 创建失败: - docker: Error response from daemon: failed to create shim task: OCI runtime create failed: runc create failed: docker run hello-world中的错误(守护程序的错误响应:OCI运行时创建失败:) - Error in docker run hello-world (Error response from daemon: OCI runtime create failed:) 我在 Ruby 中使用 open_uri 收到“docker: Error response from daemon: OCI runtime create failed” - I get "docker: Error response from daemon: OCI runtime create failed" with open_uri in Ruby 在 Windows 上通过 Docker 运行 Eclipse Che 会导致来自守护进程的错误响应:OCI 运行时创建失败 - Running Eclipse Che through Docker on Windows causes error response from daemon: OCI runtime create failed 具有.net核心的Docker 2.2:来自守护程序的错误响应:OCI运行时创建失败 - Docker with .net core 2.2: Error response from daemon: OCI runtime create failed Docker:使用卷(-v)标志运行时来自守护程序的错误响应:OCI运行时创建失败 - Docker: When running with volume (-v) flag Error response from daemon: OCI runtime create failed Docker:来自守护进程的错误响应:OCI 运行时创建失败:container_linux.go:296: - Docker: Error response from daemon: OCI runtime create failed: container_linux.go:296:
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM