1

I have tried multiple options but I just can't figure out how to access my starting foo.py file which is hiden in my directory structure.

The structure looks like this:

D:
│___ Dockerfile
│
└───Level1
    └───Level2
            foo.py

Now to start the project I need to access the foo.py file, which then works with different files spread over Level1 and 2. The problem is that I am not able to access the foo.py file with something like:

COPY /Level1 .    
CMD ["python3", "/Level1/Level2/foo.py"]

The error is python3: can't open file

Please help

3
  • "python3: can't open file" Is that the full error? Commented Oct 26, 2019 at 17:15
  • you need to copy the file to your contaoner using Dokcerfile or using volumes Commented Oct 26, 2019 at 17:30
  • What have you already done to try to debug the issue? For instance, have you looked at the filesystem layout using a debugging shell? Commented Oct 26, 2019 at 19:43

1 Answer 1

2

Your path is wrong. Change your CMD from CMD ["python3", "/Level1/Level2/foo.py"] to CMD ["python3", "/Level2/foo.py"]

You are copying from Level1/ to ., so you lose that Level1 folder.

As a side note, please include the entire error message in the post. the error message can't open file is very confusing, however the error message python3: can't open file '/Level1/Level2/foo.py': [Errno 2] No such file or directory is very clear.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.