How to prevent a bind mounted directory to be overridden by container's data
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
|
show 3 more comments
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
1
Crazy idea since I don't really know a way to do this with docer compose, you could trychattr -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, andlsattr
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 withln
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
|
show 3 more comments
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
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
docker drupal docker-compose docker-volume
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 trychattr -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, andlsattr
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 withln
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
|
show 3 more comments
1
Crazy idea since I don't really know a way to do this with docer compose, you could trychattr -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, andlsattr
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 withln
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
|
show 3 more comments
1 Answer
1
active
oldest
votes
Create a symlink from the problem directory to a non-volumed area in your docker container
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Create a symlink from the problem directory to a non-volumed area in your docker container
add a comment |
Create a symlink from the problem directory to a non-volumed area in your docker container
add a comment |
Create a symlink from the problem directory to a non-volumed area in your docker container
Create a symlink from the problem directory to a non-volumed area in your docker container
answered Nov 17 '18 at 15:06
George AppletonGeorge Appleton
620428
620428
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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, andlsattr
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