Closed hironroy closed 10 years ago
@hironroy Thanks. Your Mongo data dir (data/db
), is it inside of the project dir? Or it's located under some other path on your workstation?
If I understand your workflow correctly, you run hodor npm start
when you need to work on the project, which runs expressExample
container on the foreground and then when you done, you close this foreground process ( ctrl+c ) in terminal. Or maybe expressExample
container just runs one command and terminates after that leaving mongo running?
@gansbrest -- Thanks for the speedy reply. The idea is to have the MongoDB development data in the local project directory (ex. <project_dir>/tmp/data
). That way, I have data to play with when developing.
The mongodb
container is launched as detached (as a link dependency of the expressExample
container). The npm start
is as follows:
"start": "NODE_PATH=./config:./app/controllers NODE_ENV=development ./node_modules/.bin/nodemon server.js"
That launches an Express.js server that connects to MongoDB via Mongoose. As you said, I launch hodor npm start
when I need to work on the project and (ctrl+c) in the terminal when done.
My question is: Using Hodor, what's the best way to hookup <project_dir>/tmp/data
so that it's a volume that's mapped to the Mongo containers /data/db
directory which is where the Mongo data is stored?
Yeah, I see your point. I'll try to come up with some good solution for that, for some reason 2 volumes under same path (project dir) gives me inconsistent results right now. Thanks for the report anyways.
@hironroy I added volumes option, which you can add to container definition in docker file. __PROJECT__
is the special required "label" showing that volumes only work for path within your project. General volumes under different paths are not supported due to the nature of the tool ( which should be commited to the repo and shared between devs )
volumes:
__PROJECT__/conf: /data/conf
VERY IMPORTANT - before you test it, do docker rm -f fileshare
( remove fileshare ), then pull docker pull gansbrest/fs-base
( I updated the container ).
You can also remove your mongo container, to reinitialize volumes properly.
Let me know if it works for you as expected.
One more thing, every time you change volumes configuration of your container, you need to drop fileshare container ( docker rm -f fileshare
). In the future I may add volume change detection to avoid manual steps.
Thanks for the great utility. Everything is working as advertised. However, I can't figure out how to define a volume for the Mongo image
data/db
directory through the.hodorfile
. Currently, the MongoDB data persists until thefileshare
container is closed, but oncefileshare
is closed, the data is lost.I'm running an Express.js app backended to MongoDB and would like to persist DB data beyond the life of the docker containers. Before using Hodor, I accomplished this with this command:
docker run -d -p 27017:27017 -v
pwd/tmp/data --name mongodb dockerfile/mongodb
(after having configured Virtual Box Guest Additions).After unsuccessfully trying a number of options in
.hodorfile
, I started trying to find a relevant option in the source. Beyond the root level container (the one specified in the task), there isn't currently a way to define async_to
for a given container is there?Here is my
.hodorfile
. I launch it by executinghodor npm start
. Any help would be greatly appreciated:Thanks!