How to prevent a bind mounted directory to be overridden by container's data










1















My docker-compose.yml is like below where I have mounted my local dir code/drupal to /var/www/example.com. My container creates some temporary cache files inside /var/www/example.com/temp/. I want to map everything from container to host and host to container i.e in bidirectional but excluding the temp dir. Infact I don't want the content of that temp dir should be synchronized with my host machine.



version: "3.3"

services:

nginx:
build: ./docker/nginx
volumes:
- drupal:/var/www/example.com

volumes:
drupal:
driver: local
driver_opts:
type: none
device: $PWD/code/drupal
o: bind









share|improve this question

















  • 1





    Crazy idea since I don't really know a way to do this with docer compose, you could try chattr -R +i code/drupal/var/www/example.com/temp (correct that path as needed), so that'll make the directory immutable on your local machine. Replace +i with -i to undo, and lsattr to check attributes

    – George Appleton
    Nov 15 '18 at 9:14











  • How come you want to do this out of interest? Are the temp files massive or something?

    – George Appleton
    Nov 15 '18 at 9:15











  • Yes the temp files are massive. Infact I am using Drupal. And Drupal creates some static html/css temp files inside example.com/sites/default/files/ for caching purposes

    – SkyRar
    Nov 15 '18 at 9:19












  • Okay, I'd play around with ln and symlinking too maybe

    – George Appleton
    Nov 15 '18 at 9:21











  • So you mean symlink dir inside a container doesn't override the same dir inside host ?

    – SkyRar
    Nov 15 '18 at 9:25















1















My docker-compose.yml is like below where I have mounted my local dir code/drupal to /var/www/example.com. My container creates some temporary cache files inside /var/www/example.com/temp/. I want to map everything from container to host and host to container i.e in bidirectional but excluding the temp dir. Infact I don't want the content of that temp dir should be synchronized with my host machine.



version: "3.3"

services:

nginx:
build: ./docker/nginx
volumes:
- drupal:/var/www/example.com

volumes:
drupal:
driver: local
driver_opts:
type: none
device: $PWD/code/drupal
o: bind









share|improve this question

















  • 1





    Crazy idea since I don't really know a way to do this with docer compose, you could try chattr -R +i code/drupal/var/www/example.com/temp (correct that path as needed), so that'll make the directory immutable on your local machine. Replace +i with -i to undo, and lsattr to check attributes

    – George Appleton
    Nov 15 '18 at 9:14











  • How come you want to do this out of interest? Are the temp files massive or something?

    – George Appleton
    Nov 15 '18 at 9:15











  • Yes the temp files are massive. Infact I am using Drupal. And Drupal creates some static html/css temp files inside example.com/sites/default/files/ for caching purposes

    – SkyRar
    Nov 15 '18 at 9:19












  • Okay, I'd play around with ln and symlinking too maybe

    – George Appleton
    Nov 15 '18 at 9:21











  • So you mean symlink dir inside a container doesn't override the same dir inside host ?

    – SkyRar
    Nov 15 '18 at 9:25













1












1








1








My docker-compose.yml is like below where I have mounted my local dir code/drupal to /var/www/example.com. My container creates some temporary cache files inside /var/www/example.com/temp/. I want to map everything from container to host and host to container i.e in bidirectional but excluding the temp dir. Infact I don't want the content of that temp dir should be synchronized with my host machine.



version: "3.3"

services:

nginx:
build: ./docker/nginx
volumes:
- drupal:/var/www/example.com

volumes:
drupal:
driver: local
driver_opts:
type: none
device: $PWD/code/drupal
o: bind









share|improve this question














My docker-compose.yml is like below where I have mounted my local dir code/drupal to /var/www/example.com. My container creates some temporary cache files inside /var/www/example.com/temp/. I want to map everything from container to host and host to container i.e in bidirectional but excluding the temp dir. Infact I don't want the content of that temp dir should be synchronized with my host machine.



version: "3.3"

services:

nginx:
build: ./docker/nginx
volumes:
- drupal:/var/www/example.com

volumes:
drupal:
driver: local
driver_opts:
type: none
device: $PWD/code/drupal
o: bind






docker drupal docker-compose docker-volume






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 15 '18 at 9:05









SkyRarSkyRar

66112




66112







  • 1





    Crazy idea since I don't really know a way to do this with docer compose, you could try chattr -R +i code/drupal/var/www/example.com/temp (correct that path as needed), so that'll make the directory immutable on your local machine. Replace +i with -i to undo, and lsattr to check attributes

    – George Appleton
    Nov 15 '18 at 9:14











  • How come you want to do this out of interest? Are the temp files massive or something?

    – George Appleton
    Nov 15 '18 at 9:15











  • Yes the temp files are massive. Infact I am using Drupal. And Drupal creates some static html/css temp files inside example.com/sites/default/files/ for caching purposes

    – SkyRar
    Nov 15 '18 at 9:19












  • Okay, I'd play around with ln and symlinking too maybe

    – George Appleton
    Nov 15 '18 at 9:21











  • So you mean symlink dir inside a container doesn't override the same dir inside host ?

    – SkyRar
    Nov 15 '18 at 9:25












  • 1





    Crazy idea since I don't really know a way to do this with docer compose, you could try chattr -R +i code/drupal/var/www/example.com/temp (correct that path as needed), so that'll make the directory immutable on your local machine. Replace +i with -i to undo, and lsattr to check attributes

    – George Appleton
    Nov 15 '18 at 9:14











  • How come you want to do this out of interest? Are the temp files massive or something?

    – George Appleton
    Nov 15 '18 at 9:15











  • Yes the temp files are massive. Infact I am using Drupal. And Drupal creates some static html/css temp files inside example.com/sites/default/files/ for caching purposes

    – SkyRar
    Nov 15 '18 at 9:19












  • Okay, I'd play around with ln and symlinking too maybe

    – George Appleton
    Nov 15 '18 at 9:21











  • So you mean symlink dir inside a container doesn't override the same dir inside host ?

    – SkyRar
    Nov 15 '18 at 9:25







1




1





Crazy idea since I don't really know a way to do this with docer compose, you could try chattr -R +i code/drupal/var/www/example.com/temp (correct that path as needed), so that'll make the directory immutable on your local machine. Replace +i with -i to undo, and lsattr to check attributes

– George Appleton
Nov 15 '18 at 9:14





Crazy idea since I don't really know a way to do this with docer compose, you could try chattr -R +i code/drupal/var/www/example.com/temp (correct that path as needed), so that'll make the directory immutable on your local machine. Replace +i with -i to undo, and lsattr to check attributes

– George Appleton
Nov 15 '18 at 9:14













How come you want to do this out of interest? Are the temp files massive or something?

– George Appleton
Nov 15 '18 at 9:15





How come you want to do this out of interest? Are the temp files massive or something?

– George Appleton
Nov 15 '18 at 9:15













Yes the temp files are massive. Infact I am using Drupal. And Drupal creates some static html/css temp files inside example.com/sites/default/files/ for caching purposes

– SkyRar
Nov 15 '18 at 9:19






Yes the temp files are massive. Infact I am using Drupal. And Drupal creates some static html/css temp files inside example.com/sites/default/files/ for caching purposes

– SkyRar
Nov 15 '18 at 9:19














Okay, I'd play around with ln and symlinking too maybe

– George Appleton
Nov 15 '18 at 9:21





Okay, I'd play around with ln and symlinking too maybe

– George Appleton
Nov 15 '18 at 9:21













So you mean symlink dir inside a container doesn't override the same dir inside host ?

– SkyRar
Nov 15 '18 at 9:25





So you mean symlink dir inside a container doesn't override the same dir inside host ?

– SkyRar
Nov 15 '18 at 9:25












1 Answer
1






active

oldest

votes


















1














Create a symlink from the problem directory to a non-volumed area in your docker container






share|improve this answer






















    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53315777%2fhow-to-prevent-a-bind-mounted-directory-to-be-overridden-by-containers-data%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    Create a symlink from the problem directory to a non-volumed area in your docker container






    share|improve this answer



























      1














      Create a symlink from the problem directory to a non-volumed area in your docker container






      share|improve this answer

























        1












        1








        1







        Create a symlink from the problem directory to a non-volumed area in your docker container






        share|improve this answer













        Create a symlink from the problem directory to a non-volumed area in your docker container







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 17 '18 at 15:06









        George AppletonGeorge Appleton

        620428




        620428





























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53315777%2fhow-to-prevent-a-bind-mounted-directory-to-be-overridden-by-containers-data%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            這個網誌中的熱門文章

            Barbados

            How to read a connectionString WITH PROVIDER in .NET Core?

            Node.js Script on GitHub Pages or Amazon S3