42
20
I have two Dart applications I need to dockerize. These two apps use a shared source directory.
Because Docker prevents adding files from folders outside the context directory (project/app1
) I can't add files from ../shared
nor from shared
(the symlink inside projects/app1
).
I'm looking for a way to trick Docker to do it anyway.
My simplified project structure
- projects
- app1
- Dockerfile
- shared (symlink ../shared)
- otherSource
- app2
- Dockerfile
- shared (symlink ../shared)
- otherSource
- shared
- source
I could move Dockerfile
one level up and run docker build
from there but then I need two Dockerfiles (for app1 and app2) in the same directory.
My current idea was, if I could somehow hide the fact that projects/app1/shared
is a symlink this problem would be solved.
I checked if I can share projects
using Samba and remount it somewhere else and configure Samba to treat symlinks like normal folders but haven't found whether this is supported (I have not much experience with Samba and not tried it yet, just searched a bit).
Is there any other tool or trick that would allow that?
I would rather not change the directory structure because this would cause other troubles and also rather not copy files around.
1@zoechi this is perfectly on topic on both sites. As a general rule, I would post more technical questions like this on U&L and more user-space questions here. The choice is completely up to you though. On the one hand, there are more users here so more eyeballs, on the other, there is a much higher concentration of professional *nix people on U&L. Just make sure you don't post the same question on both sites. If you want to move it, either delete this or flag for mod attention and ask them to migrate. – terdon – 2014-11-20T13:05:07.320
2It was mandatory for me to restart docker daemon! Else the mounted dir was not visible in the container. – dim – 2016-01-22T11:25:25.407
@dim yes! I tried to get it to work with Capistrano and it didn't work – turns out I mounted the shared directories after I started the container – csch – 2016-11-07T14:18:15.613
Unfortunately this won't work for Windows or OS X users. The debate about this issue has been... lively. – Jason – 2017-02-24T01:34:58.973
is mounting 'commited' to source control eg github? or would I have to do it every time? – pie6k – 2019-03-14T11:22:23.857
@pie6k how could it be committed? Source control tracks changes in text files, not commands run on the system. – terdon – 2019-03-14T11:25:49.213