skip to Main Content

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" ]

2

Answers


  1. Chosen as BEST ANSWER

    I fixed that by the following Dockerfile:

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

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

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search