简体   繁体   中英

Docker can't run the file

When I prescribe docker-compose up, the following error comes out, which I don't quite understand how to fix!

ERROR: for a1e9335fc0e8_bot Cannot start service tgbot: failed to create shim: OCI runtime create failed: runc create failed: unable to start container process: exec: "python3 main.py": executable file not found in $PATH: unknown

My Dockerfile:

FROM python:latest

WORKDIR /src
COPY req.txt /src
RUN pip install -r req.txt
COPY . /src 

My docker-compose.yml:

version: "3.1"

services:
  db:
    container_name: database
    image: sameersbn/postgresql:10-2
    environment:
      PG_PASSWORD: $PGPASSWORD
    restart: always
    ports:
      - 5432:5432
    networks:
      - botnet
    volumes:
      - ./pgdata:/var/lib/postgresql

  tgbot:
      container_name: bot
      build:
        context: .
      command:
        - python3 main.py
      restart: always
      networks:
        - botnet
      env_file:
        - ".env"
      depends_on:
        - db


networks:
  botnet:
    driver: bridge

Your command: is in the array format, so compose thinks that the executable file is called python3 main.py . That doesn't exist.

Change it to this and it'll work

tgbot:
  container_name: bot
  build:
    context: .
  command: python3 main.py
  restart: always
  networks:
    - botnet
  env_file:
    - ".env"
  depends_on:
    - db

More info here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM