Accessing other files with path in docker image

I’m new to Docker. I have created a docker image for a large python script containing many files. When I run the image, the CMD works and the right file runs. However, I’m having issues accessing other files within my code using paths in Python. When I run the script on my computer there is no problem.

Here is the Dockerfile:

FROM python:3.11.6

ADD /ReportGeneration/ .

RUN pip install -r requirements.txt

CMD [“python”,“BasicReports/Instagram/GenerateIGReport.py”]

I get this error running the image:
FileNotFoundError: [Errno 2] No such file or directory: 'BasicReports\\Instagram\\DBUpload\\Credentials\\DB_uri.json'

As the path worked in the CMD, I presumed it would also work in the docker image. Can someone advise on how to fix this? Thanks!

Start with WORKDIR, use more simple COPY.

I assume the container exits immediately, you could use a very manual CMD ["ls", "-la", "BasicReports/Instagram"] and deeper paths to check which files are inside the container.

On second thought, your hardcoded path is probably using escaped Windows path separator (\\), in regular Linux containers you need to use /.

Thanks for the reply! Yes you are right about Linux path being the cause of the problem. I’m trying to access a pip package (wkhtmltopdf) which normally requires you to access the wkhtmltopdf.exe file using the path on your computer. Would you know what the right path is locally to the Docker image?

There is no .exe on Linux.