Skip to content
Advertisement

Why does my Python file directory structure not match my Dockerfile output?

My Dockerfile (run by a much larger docker-compose):

JavaScript

and the relevant code from the docker-compose.yml:

JavaScript

The Python code I’m using to check the directory structure:

JavaScript

and its output:

JavaScript

I don’t understand why the directory structure seen/output by the Dockerfile would be completely different from the directory structure seen/output by my Python file. For some reason, even though the Python code is run by (and inside) the Docker container and only specific files and folders are copied, the file system seen/output by Python seems to match my host system’s file structure:
Host system file structure

Clearly some stuff is getting copied but not at all what I would expect based on my Dockerfile commands and the output from said Dockerfile.


Please let me know if I need to add more information.

Advertisement

Answer

Your Compose file specifies:

JavaScript

This indicates that the /code/models directory in the image, and whatever setup you’ve done locally on it, should be hidden and replaced with the named host directory.

Your image already contains the models, though, and it’s done some additional pre-processing on them. You should delete this volumes: block so that you see the original contents of the image.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement