Skip to content
This repository has been archived by the owner on Aug 30, 2021. It is now read-only.

Mount a host directory as a data volume in Docker #1053

Closed
lvarayut opened this issue Nov 9, 2015 · 2 comments
Closed

Mount a host directory as a data volume in Docker #1053

lvarayut opened this issue Nov 9, 2015 · 2 comments
Assignees

Comments

@lvarayut
Copy link

lvarayut commented Nov 9, 2015

Should we mount a host directory as a data volume in docker-compose.yml? So, we could develop on our local machine, and keep our codes sync between the local machine and a docker machine? As following:

web:
  build: .
  links:
   - db
  ports:
   - "3000:3000"
  environment: 
   NODE_ENV: development
  volumes:
    - .:/home/mean
db:
  image: mongo
  ports: 
   - "27017:27017"
@codydaig
Copy link
Member

codydaig commented Nov 9, 2015

@lvarayut I would like to refrain from mounting the volume permanently. Isn't there something in the README that describes how to do this?

@lvarayut
Copy link
Author

Do you mean the following command?

$ docker run -p 3000:3000 -p 35729:35729 -v /Users/mdl/workspace/mean-stack/mean/public:/home/mean/public -v /Users/mdl/workspace/mean-stack/mean/app:/home/mean/app --link db:db_1 mean

So, if I wanted to mount the volume, I can't do it with docker-compose up command but instead I have to manually mount it by using the command above. In other word, I had to do the following steps:

$ docker build -t mean .
$ docker run -p 27017:27017 -d --name db mongo
$ docker run -p 3000:3000 -p 35729:35729 -v /Users/mdl/workspace/mean-stack/mean/public:/home/mean/public -v /Users/mdl/workspace/mean-stack/mean/app:/home/mean/app --link db:db_1 mean

Is that what you meant? The conclusion is that we couldn't use docker-compose up in this case.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants