简体   繁体   English

在 $PATH 中找不到 Docker 撰写可执行文件”:未知

[英]Docker compose executable file not found in $PATH": unknown

but I'm having a problem.但我遇到了问题。

Dockerfile: Dockerfile:

FROM python:3
ENV PYTHONUNBUFFERED 0
RUN mkdir /code
WORKDIR /code
COPY requirements.txt /code/
RUN pip install -r requirements.txt
COPY . /code/

compose.yml : compose.yml :

version: '3'

services:
  db:
    image: postgres
    volumes:
      - ./docker/data:/var/lib/postgresql/data
    environment:
      - POSTGRES_DB=sampledb
      - POSTGRES_USER=sampleuser
      - POSTGRES_PASSWORD=samplesecret
      - POSTGRES_INITDB_ARGS=--encoding=UTF-8

  django:
    build: .
    environment:
      - DJANGO_DEBUG=True
      - DJANGO_DB_HOST=db
      - DJANGO_DB_PORT=5432
      - DJANGO_DB_NAME=sampledb
      - DJANGO_DB_USERNAME=sampleuser
      - DJANGO_DB_PASSWORD=samplesecret
      - DJANGO_SECRET_KEY=dev_secret_key
    ports:
      - "8000:8000"
    command:
      - python3 manage.py runserver
    volumes:
      - .:/code

error :错误 :

ERROR: for django  Cannot start service django: OCI runtime create failed: container_linux.go:346: starting container process caused "exec: \"python3 manage.py runserver\": executable file not found in $PATH": unknown

At first, I thought Python Manage was wrong.起初,我认为 Python Manage 是错误的。

But i tried command ls , To my surprise, I succeeded.但是我尝试了命令ls ,令我惊讶的是,我成功了。

Then I tried the ls -al command, but it failed.然后我尝试了 ls -al 命令,但它失败了。

I think the addition of a command to write space is causing a problem.我认为添加写入空间的命令会导致问题。

how can i fix it ?我该如何解决?

When you use list syntax in the docker-compose.yml file, each item is taken as a word.当您在docker-compose.yml文件中使用列表语法时,每一项都被视为一个词。 You're running the shell equivalent of您正在运行相当于

'python3 manage.py runserver'

You can either break this up into separate words yourself你可以自己把它分解成单独的词

command:
  - python3
  - manage.py
  - runserver

or have Docker Compose do it for you或者让 Docker Compose 为你做

command: python3 manage.py runserver

In general fixed properties of the image like this should be specified in the Dockerfile, not in the docker-compose.yml .一般来说,像这样的图像的固定属性应该在 Dockerfile 中指定,而不是在docker-compose.yml Every time you run this image you're going to want to run this same command, and you're going to want to run the code built into the image.每次运行此映像时,您都需要运行相同的命令,并且需要运行内置于映像中的代码。 There are two syntaxes, with the same basic difference:有两种语法,具有相同的基本区别:

# Explicitly write out the words
CMD ["python3", "manage.py", "runserver"]

# Docker wraps in sh -c '...' which splits words for you
CMD python3 manage.py runserver

With the code built into the image and a reasonable default command defined there, you can delete the volumes: and command: from your docker-compose.yml file.使用图像中内置的代码和其中定义的合理默认命令,您可以从docker-compose.yml文件中删除volumes:command:

暂无
暂无

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

相关问题 docker:在 $PATH 中找不到可执行文件”:未知 - docker: executable file not found in $PATH": unknown docker-compose exec: \“webserver\”: $PATH 中找不到可执行文件 - docker-compose exec: \“webserver\”: executable file not found in $PATH uWSGI + Docker:pyuwsgi:在$ PATH中找不到可执行文件 - uWSGI + Docker: pyuwsgi: executable file not found in $PATH docker-compose无法启动服务:“ exec:\\” python3 \\”:找不到可执行文件 - docker-compose cannot start service: “exec: \”python3\": executable file not found 如何解决“exec:\”Python\“:$PATH 中找不到可执行文件”:未知。 用于 AWS 上的简单 python 脚本 - How to solve “exec: \”Python\“: executable file not found in $PATH”: unknown. for simple python script on AWS 启动容器进程导致:exec:“uvicorn”:$PATH 中找不到可执行文件:未知 - starting container process caused: exec: "uvicorn": executable file not found in $PATH: unknown 从python运行时,Docker映像给我“在$ PATH中找不到可执行文件” - Docker image gives me “executable file not found in $PATH” when run from python "exec: "python": $PATH 中找不到可执行文件 - "exec: "python": executable file not found in $PATH “python”:在 M1 上的 $PATH 中找不到可执行文件 - "python": executable file not found in $PATH on M1 FastAPI docker-compose文件未找到错误 - FastAPI docker-compose File Not Found Error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM