S
S
S1riyS2021-12-31 15:16:49
Python
S1riyS, 2021-12-31 15:16:49

Why do I get the error "python: can't open file '//temp/hello_world.py': [Errno 2] No such file or directory" when running an image?

docker-compose.yml :

version: '3.9'
services:
  python_runner:
    build:
       context: ./compilers/python
       dockerfile: Dockerfile
    volumes:
       - ./temp:/temp 
    container_name: python_runner_container 
    environment:
      - FILENAME=${FILENAME}

  java_runner:
    ...

Dockerfile to run python :
FROM python
ARG FILENAME_ARG
ENV FILENAME = $FILENAME_ARG
CMD python temp/${FILENAME}

First, I go to the c folder docker-composeand run it with the command:
docker-compose up -d

Then I try to run the image that executes python:
docker run --env FILENAME=hello_world.py compilers_python_runner

But in the output I get an error:
python: can't open file '//temp/hello_world.py': [Errno 2] No such file or directory

Interestingly, when I run through the PyCharmdocker-compose interface and manually set the value of the variable , everything works correctly. What is the error and how to fix it? FILENAME

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question