Flask app in container can't find program file at location where it definitely is at

Hello all, new docker user here, having a rocky experience with the software so far. I hope you don’t mind helping me out with a weird docker error.

I’ve got a python program I wrote for a coding bootcamp that I’m now trying to containerize. It runs in terminal, and I’ve adapted pyxtermjs, a flask/flask-socketio app, to run it.

In the ENTRYPOINT, pyxtermjs’s app.py is called with the path to my program, advgame.py, as an argument. It listens on port 5000 and with every connection it’s meant to use subprocess.run() to call my program.

But it fails with a FileNotFoundError. According to the flask app, there’s no such file or directory.

However, I’ve verified the file is there. I used docker exec -it <container_id> /bin/sh to double check that COPY . /app hadn’t missed a spot. Yes, /app/advgame.py was definitely where I left it. I confirmed with a print(os.getcwd()) line that the flask app is running from /app. I’ve tried advgame.py, ./advgame.py and /app/advgame.py, none finds the file.

Is the flask app being run in some sort of isolation where it’s not allowed to access other files in the container? That’s the only thing I can think of. Why can’t the ENTRYPOINT flask app find my program in the container at the location where it definitely is?

Hi kernefahey,

Did you ever solve this issue. I’m having a similar problem where on my local machine I have a csv file stored at the same level as my main.py file which it can access no problem. However, when I copy it over to Docker, the file cannot be found even though after checking the Docker files it exists in the exact same location as my local machine.