Python import error in Docker compoment

I try to package my code in image using code below:

FROM torch_gpu:v1
WORKDIR /app
COPY ./code/* ./
CMD ["python","main.py"]

when I try to run it with docker run . It goes wrong with

  File "/app/main.py", line 30, in load_AU_model
    from OpenGraphAU.conf import get_config, set_env, set_outdir, set_logger
ModuleNotFoundError: No module named 'OpenGraphAU'

The file dir tree is

/app
---/OpenGraphAU
   ----conf.py
---main.py

I don’t kown where is wrong and how to fix it?

but when I try run it with docker run --mount type=bind,source=./code,target=/app, it work well.

I have added code to changed envirment var and it work well

os.chdir("/app")
curPath = os.path.abspath(os.path.dirname(__file__))
rootPath = os.path.split(curPath)[0]
sys.path.insert(0, os.path.split(rootPath)[0])
sys.path.remove("/") 
print(sys.path)

and ouput

['/app', '/opt/conda/lib/python311.zip', '/opt/conda/lib/python3.11', '/opt/conda/lib/python3.11/lib-dynload', '/opt/conda/lib/python3.11/site-packages', '/opt/conda/lib/python3.11/site-packages/setuptools/_vendor', '/tmp/tmpz4y0cvod']

Where did you run the command to test it (in the container or on the host) and what command you ran? If mounting works but copying files into the image doesn’t, you either copy the wrong files or to the wrong folder in the image, or when you run the container you override the original code and eventually it will not be found in the container even if it was in the image..