11

I would like to mount everything inside my current directory, except /node_modules and /client/bower_components. I currently have to manually mount all the paths as following:

app:
  build: .
  ports:
    - "3000:3000"
    - "35729:35729"
  links:
    - mongo
  volumes:
    - client/app:/www/app/client/app
    - client/assets:/www/app/client/assets
    - client/components:/www/app/client/components
    - server:/www/app/server
    ...
mongo:
  image: mongo
  ports:
    - "27017:27017"

Is there somehow I can exclude some paths, for example !client/bower_components and !node_modules?

lvarayut
  • 13,963
  • 17
  • 63
  • 87
  • 1
    You can find a solution here http://stackoverflow.com/questions/29181032/add-a-volume-to-docker-but-exclude-a-sub-folder –  Nov 09 '16 at 07:09
  • 1
    @impactmass, Specifically the solution can be find in https://stackoverflow.com/a/37898591/1875049 – Sina Masnadi May 30 '17 at 20:29
  • 1
    Possible duplicate of [Add a volume to Docker, but exclude a sub-folder](https://stackoverflow.com/questions/29181032/add-a-volume-to-docker-but-exclude-a-sub-folder) – Louis Aug 12 '19 at 15:05

1 Answers1

2

Yes, you can.

There are answers to this question here and here.

For quick reference, the solution is below.

volumes:
  - ./parent:/usr/share/elasticsearch/parent
  - /usr/share/elasticsearch/parent/node_modules/

Here are the docker volume docs

Preston
  • 7,399
  • 8
  • 54
  • 84