Home > database >  Docker compose can't open python file
Docker compose can't open python file

Time:08-22

I runned docker compose file using the docker-compose up command that supposed to run some python script, but I got an error that says that he cannot open the python sciprt I gave him, this is the error:

python3: can't open file '//relay.py': [Errno 2] No such file or director

this is the full error when running the command: image from terminal

Can someone help me fix this error?

this is my files directory:

/dockers/docker-compose.yml
/dockers/relay-codes/relay.py
/dockers/relay-codes/Dockerfile

Docker-compose.yml:

version: '3'

services:
  relays:
    build: ./relay-codes
    volumes:
      - ./relay-codes:/usr/src/app
    ports:
      - 5001:9898

Dockerfile:

FROM python:latest

COPY . /usr/src/app

CMD [ "python3", "./relay.py" ]

CodePudding user response:

I fixed that by the following Dockerfile:

FROM python:latest
WORKDIR /usr/src/app
COPY relay.py /usr/src/app/
CMD ["python3", "relay.py"]

CodePudding user response:

The exception is providing you all the clue that you need. There's no file at that location.

  • Related