I’m using a specific mounting pattern in my docker-compose.yml file where I bind mount a local host directory to the exact same absolute path inside the container.
The configuration looks similar to this:
services:
<example-application>:
image: <example-application>/<example-application>:SNAPSHOT
ports:
- "4440:4440"
volumes:
# Mount <example-application> configuration files matching internal structures:
- ./<example-application>/scripts:/home/<example-application>/scripts
- ./<example-application>/server/config/realm.properties:/home/<example-application>/server/config/realm.properties:ro
- ./<example-application>/etc/profile:/home/<example-application>/etc/profile:ro
By doing this, a file located at
./<example-application>/scripts
on my host machine is accessible at the exact same path
/home/<example-application>/scripts
inside the running container. This is incredibly useful for debugging tools and compilers that output absolute paths, as it eliminates the need to translate paths between the host and the container.