Reputation: 190
I've created a nodejs application which uses external files to read various configurations and I've created a docker container for this app. I need this app to read the config files (since they will be changed from time to time) from the host machine without rebuilding the whole docker container. How can this be done?
Upvotes: 2
Views: 1547
Reputation: 4973
You should use docker volumes to read those config files from your host.
docker run -v /host/config_files:/container/nodejs/config_files
Your nodejs application can just access the files residing in /container/nodejs/config_files
while you can change them on your host.
var config = require('./config_files/some.properties');
I did something similar for a dev project of mine.
My approach was to use an ENTRYPOINT
that clones the git repo everytime the container is started and automatically starts the nodejs service.
This is achieved in the Dockerfile with
FROM ...
...
ENTRYPOINT git clone https://github.com/my/repo.git && nodejs someService
Other ideas:
ENTRYPOINT
commandUpvotes: 3