Docker Community Forums

Share and learn in the Docker community.

Expose file like a volume

Hi all! I’m preety new at docker and docker-compose.
I’m working with docker for windows and triying to expose a single properties file from my docker container to my host.
But the container allways make a directory.
It’s some way to create a file instantead a directory?
I’m using this declaration:
volumes:
- ‘./mnt/myApp/configs/my-config.properties:/opt/myApp/configs/my-config.properties’

If I can’t expose a single file as volume, can I copy that file into the folder when the container is starting?

Thanks in advance!

Not supported in Docker for Windows. Only folder mappings are supported.

Nope. But, you can copy a file into a running container after its started: docker cp /path/to/local/file container:/path/in/container. If you put into consideration that docker containers are disposable by design, I wouldn’t waste time on docker cp, as the change will be lost when the container needs to be re-created (e.g. for an image update).

Why don’t you map the whole configs folder from the host to the container? At least this would be more reliable.

Thanks a lot for your help!

I’m just triying to automatize the configuration for this aplication.
Sadly, the main configurations are in the root folder of the app, so, if I expose that, I expose all the app in the folder.
So, maybe the best aproach is make an ‘custom image’ when all the configs are copied to the container, right?

Thanks again!