How can I change permission of mounted volumes in docker-compose.yml from the docker-compose.yml? - Stack Overflow (https://cdn.sstatic.net/Sites/stackoverflow/Img/favicon.ico?v=ec617d715196) (https://cdn.sstatic.net/Sites/stackoverflow/Img/apple-touch-icon.png?v=c78bd457575a) (https://cdn.sstatic.net/Sites/stackoverflow/Img/apple-touch-icon.png?v=c78bd457575a) (Stack Overflow) (/opensearch.xml) (https://stackoverflow.com/questions/50325494/how-can-i-change-permission-of-mounted-volumes-in-docker-compose-yml-from-the-do) (https://cdn.sstatic.net/Shared/stacks.css?v=bd2aba62c5a4) (https://cdn.sstatic.net/Sites/stackoverflow/primary.css?v=cc49ce762956) (Feed for question 'How can I change permission of mounted volumes in docker-compose.yml from the docker-compose.yml?') (/feeds/question/50325494) (https://cdn.sstatic.net/Shared/Channels/channels.css?v=5981bb1a5bd7) (https://accounts.google.com/gsi/style) (site logo) Join Stack Overflow By clicking “Sign up”, you agree to our (/legal/terms-of-service/public) terms of service and acknowledge you have read our (/legal/privacy-policy) privacy policy . (8715abeb62cf6a9fe93de824cea527599cbf4e957f73c9d6615a4213f6b2728c) (1) (2.0) Sign up with Google Sign up with GitHub OR (8715abeb62cf6a9fe93de824cea527599cbf4e957f73c9d6615a4213f6b2728c) (1) () () () () () () Email Password (8+ characters (at least 1 letter & 1 number)) Sign up Already have an account? (/users/login) Log in (8715abeb62cf6a9fe93de824cea527599cbf4e957f73c9d6615a4213f6b2728c) () Skip to main content (https://stackoverflow.com) Stack Overflow (https://stackoverflow.co/) About Products (https://stackoverflow.co/teams/ai/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav-bar&utm_content=overflowai) OverflowAI (https://stackoverflow.co/teams/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav&utm_content=stack-overflow-for-teams) Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers (https://stackoverflow.co/advertising/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav&utm_content=stack-overflow-advertising) Advertising & Talent Reach devs & technologists worldwide about your product, service or employer brand (https://stackoverflow.co/teams/ai/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav&utm_content=overflow-ai) OverflowAI GenAI features for Teams (https://stackoverflow.co/api-solutions/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav&utm_content=overflow-api) OverflowAPI Train & fine-tune LLMs (https://stackoverflow.co/labs/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav&utm_content=labs) Labs The future of collective knowledge sharing (https://stackoverflow.co/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav&utm_content=about-the-company) About the company (https://stackoverflow.blog/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav&utm_content=blog) Visit the blog (Search…) () Loading… (https://stackoverflow.com) current community (https://stackoverflow.com) (Stack Overflow) Stack Overflow (https://stackoverflow.com/help) help (https://chat.stackoverflow.com/?tab=site&host=stackoverflow.com) chat (https://meta.stackoverflow.com) (Meta Stack Overflow) Meta Stack Overflow your communities (https://stackoverflow.com/users/signup?ssrc=site_switcher&returnurl=https%3a%2f%2fstackoverflow.com%2fquestions%2f50325494%2fhow-can-i-change-permission-of-mounted-volumes-in-docker-compose-yml-from-the-do) Sign up or (https://stackoverflow.com/users/login?ssrc=site_switcher&returnurl=https%3a%2f%2fstackoverflow.com%2fquestions%2f50325494%2fhow-can-i-change-permission-of-mounted-volumes-in-docker-compose-yml-from-the-do) log in to customize your list. (https://stackexchange.com/sites) more stack exchange communities (https://stackoverflow.blog) company blog (Click to show search) (https://stackoverflow.com/users/login?ssrc=head&returnurl=https%3a%2f%2fstackoverflow.com%2fquestions%2f50325494%2fhow-can-i-change-permission-of-mounted-volumes-in-docker-compose-yml-from-the-do) Log in (https://stackoverflow.com/users/signup?ssrc=head&returnurl=https%3a%2f%2fstackoverflow.com%2fquestions%2f50325494%2fhow-can-i-change-permission-of-mounted-volumes-in-docker-compose-yml-from-the-do) Sign up Ask questions and share your thoughts on the future of Stack Overflow. Join our first live community AMA this Wednesday, February 26th, at 3 PM ET. (https://meta.stackexchange.com/questions/406399/join-us-for-our-first-community-wide-ama-ask-me-anything-with-stack-overflow-s?utm_medium=ppc&utm_source=stackoverflow-community&utm_campaign=community-ama&utm_content=announcement-banner2) Learn more (dismiss) Let's set up your homepage Select a few topics you're interested in: python javascript c# reactjs java android html flutter c++ node.js typescript css r php angular next.js spring-boot machine-learning sql excel ios azure docker Or search from our full list: (Search) javascript python java c# php android html jquery c++ css ios sql mysql r reactjs node.js arrays c asp.net json python-3.x .net ruby-on-rails sql-server swift django angular objective-c excel pandas angularjs regex typescript ruby linux ajax iphone vba xml laravel spring asp.net-mvc database wordpress string flutter postgresql mongodb wpf windows amazon-web-services xcode bash git oracle-database spring-boot dataframe azure firebase list multithreading docker vb.net react-native eclipse algorithm powershell macos visual-studio numpy image forms scala function vue.js performance twitter-bootstrap selenium winforms kotlin loops express dart hibernate sqlite matlab python-2.7 shell rest apache entity-framework android-studio csv api maven linq qt dictionary unit-testing facebook asp.net-core tensorflow apache-spark file swing class unity-game-engine sorting date authentication go symfony opencv t-sql matplotlib .htaccess google-chrome for-loop datetime codeigniter http perl validation sockets google-maps object uitableview xaml oop if-statement visual-studio-code cordova ubuntu web-services email android-layout github elasticsearch spring-mvc kubernetes selenium-webdriver ms-access user-interface parsing ggplot2 pointers machine-learning c++11 google-sheets security flask google-apps-script ruby-on-rails-3 nginx templates variables exception sql-server-2008 gradle debugging tkinter listview delphi jpa asynchronous pdf web-scraping haskell jsp ssl amazon-s3 google-cloud-platform jenkins testing xamarin wcf npm batch-file generics ionic-framework network-programming unix recursion google-app-engine mongoose visual-studio-2010 .net-core android-fragments assembly animation math next.js session svg hadoop intellij-idea curl django-models join laravel-5 winapi rust url heroku http-redirect tomcat google-cloud-firestore inheritance webpack keras image-processing asp.net-mvc-4 gcc web logging dom swiftui matrix pyspark actionscript-3 button post optimization firebase-realtime-database jquery-ui cocoa iis xpath d3.js firefox javafx internet-explorer xslt caching select asp.net-mvc-3 opengl events asp.net-web-api plot dplyr magento encryption search stored-procedures amazon-ec2 ruby-on-rails-4 memory audio canvas multidimensional-array jsf random vector cookies redux facebook-graph-api input flash xamarin.forms indexing arraylist ipad cocoa-touch data-structures video apache-kafka model-view-controller serialization jdbc woocommerce routes razor awk azure-devops servlets mod-rewrite beautifulsoup docker-compose iframe filter excel-formula aws-lambda design-patterns text django-rest-framework visual-c++ cakephp mobile android-intent react-hooks struct methods groovy mvvm ssh lambda checkbox google-chrome-extension ecmascript-6 time grails installation sharepoint cmake spring-security shiny jakarta-ee android-recyclerview plsql core-data types meteor android-activity sed bootstrap-4 websocket activerecord graph replace scikit-learn file-upload group-by vim junit deep-learning boost import sass memory-management error-handling async-await eloquent dynamic soap silverlight dependency-injection charts layout apache-spark-sql deployment browser gridview svn while-loop google-bigquery vuejs2 ffmpeg dll highcharts view foreach plugins makefile c#-4.0 redis reporting-services jupyter-notebook server merge https unicode reflection google-maps-api-3 twitter oauth-2.0 extjs pytorch axios terminal pip split mysqli cmd django-views encoding automation netbeans database-design collections hash build data-binding ember.js tcp sqlalchemy pdo apache-flex concurrency command-line entity-framework-core spring-data-jpa printing java-8 react-redux jestjs service html-table neo4j ansible lua parameters material-ui module visual-studio-2012 enums promise flexbox outlook webview firebase-authentication web-applications uwp jquery-mobile utf-8 datatable python-requests parallel-processing drop-down-menu colors scroll hive tfs scipy count syntax ms-word twitter-bootstrap-3 ssis google-analytics three.js fonts powerbi constructor graphql rxjs file-io paypal discord cassandra socket.io graphics compiler-errors gwt nlp react-router solr backbone.js url-rewriting datatables memory-leaks oauth datagridview terraform drupal oracle11g zend-framework neural-network knockout.js triggers django-forms interface google-api angular-material casting jmeter linked-list proxy path timer django-templates arduino orm directory parse-platform visual-studio-2015 windows-phone-7 cron push-notification conditional-statements primefaces functional-programming pagination model jar xamarin.android hyperlink uiview visual-studio-2013 gitlab vbscript google-cloud-functions azure-active-directory jwt download swift3 sql-server-2005 process configuration rspec properties pygame combobox callback windows-phone-8 safari linux-kernel permissions scrapy raspberry-pi scripting emacs clojure scope io x86 compilation mongodb-query responsive-design nhibernate angularjs-directive request expo bluetooth 3d dns azure-functions binding reference discord.js architecture playframework pyqt version-control doctrine-orm package pycharm get sql-server-2012 rubygems f# autocomplete datepicker openssl kendo-ui tree controller jackson yii nested grep xamarin.ios static statistics dockerfile transactions null datagrid active-directory uiviewcontroller phpmyadmin webforms discord.py notifications computer-vision sas duplicates mocking youtube nullpointerexception yaml menu sum bitmap electron asp.net-mvc-5 visual-studio-2008 time-series yii2 jsf-2 android-listview css-selectors stl blazor floating-point cryptography ant stream hashmap character-encoding msbuild sdk asp.net-core-mvc google-drive-api selenium-chromedriver jboss joomla navigation cors devise anaconda frontend background camera pyqt5 multiprocessing binary cuda linq-to-sql iterator mariadb onclick ios7 plotly rabbitmq android-asynctask android-jetpack-compose microsoft-graph-api tabs insert laravel-4 amazon-dynamodb uicollectionview environment-variables linker console xsd coldfusion upload continuous-integration ftp textview opengl-es operating-system mockito vuejs3 localization xml-parsing macros formatting json.net kivy type-conversion data.table timestamp calendar integer segmentation-fault android-ndk drag-and-drop prolog char crash jasmine automated-tests dependencies geometry android-gradle-plugin itext firebase-cloud-messaging header sprite-kit mfc fortran attributes nosql nuxt.js format nestjs azure-pipelines odoo jquery-plugins db2 leaflet jenkins-pipeline event-handling postman flutter-layout annotations julia keyboard textbox arm visual-studio-2017 gulp libgdx stripe-payments xampp synchronization crystal-reports azure-web-app-service timezone dom-events android-emulator swagger uikit wso2 sequelize.js aggregation-framework namespaces uiscrollview jvm chart.js google-sheets-formula com subprocess geolocation centos webdriver html5-canvas widget garbage-collection dialog numbers snowflake-cloud-data-platform concatenation sql-update qml windows-10 set mapreduce tuples smtp ionic2 java-stream rotation modal-dialog android-edittext spring-data http-headers nuget doctrine radio-button grid sonarqube lucene xmlhttprequest internationalization listbox components initialization switch-statement google-play apache-camel boolean serial-port ldap ios5 youtube-api return gdb latex pivot eclipse-plugin frameworks tags containers dataset github-actions asp-classic foreign-keys subquery label copy uinavigationcontroller google-cloud-storage delegates c++17 struts2 migration base64 protractor queue sql-server-2008-r2 find uibutton embedded arguments composer-php append jaxb zip stack cucumber autolayout ide entity-framework-6 popup iteration windows-7 airflow r-markdown ssl-certificate vb6 gmail hover jqgrid tailwind-css g++ udp Next You’ll be prompted to create an account to view your personalized homepage. (/) Home (/questions) Questions (/tags) Tags (/users) Users (https://stackoverflow.com/jobs/companies?so_medium=stackoverflow&so_source=SiteNav) Companies Labs (/jobs?source=so-left-nav) Jobs (/beta/discussions) Discussions Collectives Communities for your favorite technologies. (/collectives-all) Explore all Collectives Teams () Ask questions, find answers and collaborate at work with Stack Overflow for Teams. (https://stackoverflowteams.com/teams/create/free/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=side-bar&utm_content=explore-teams) Try Teams for free (https://stackoverflow.co/teams/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=side-bar&utm_content=explore-teams) Explore Teams Teams Ask questions, find answers and collaborate at work with Stack Overflow for Teams. (https://stackoverflow.co/teams/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=side-bar&utm_content=explore-teams-compact) Explore Teams Collectives™ on Stack Overflow Find centralized, trusted content and collaborate around the technologies you use most. (/collectives) Learn more about Collectives Teams Q&A for work Connect and share knowledge within a single location that is structured and easy to search. (https://stackoverflow.co/teams/) Learn more about Teams Get early access and see previews of new features. (https://stackoverflow.co/labs/) Learn more about Labs (Illustration of upvote icon after it is clicked) Hang on, you can't upvote just yet. You'll need to complete a few actions and gain 15 reputation points before being able to upvote. Upvoting indicates when questions and answers are useful. (https://stackoverflow.com/help/whats-reputation) What's reputation and how do I get it? Instead, you can save this post to reference later. Save this post for later Not now (https://cdn.sstatic.net/Sites/stackoverflow/Img/apple-touch-icon.png?v=c78bd457575a) (/questions/50325494/how-can-i-change-permission-of-mounted-volumes-in-docker-compose-yml-from-the-do) How can I change permission of mounted volumes in docker-compose.yml from the docker-compose.yml? (/questions/ask) Ask Question (2018-05-14 07:54:21Z) Asked 6 years, 9 months ago Modified (?lastactivity) (2022-03-29 19:21:39Z) 2 years, 11 months ago (Viewed 230,198 times) Viewed 230k times This question shows research effort; it is useful and clear (70:3:31e,16:c045974ec815cee9,10:1740413509,16:85fddbca778c0d88,8:50325494,27575d99dc231fb239db44f740ee8ff76559983a0b2987376f3d5a5cbfa85e9f) 88 (This question does not show any research effort; it is unclear or not useful) (70:3:31e,16:af31300a450a6d2f,10:1740413509,16:e7a89885b1bd788d,8:50325494,21d60aef252c5899aa08b77d14d1520627d58e2d46ffbd986c8b2c76add55ec9) Save this question. (/posts/50325494/timeline) Show activity on this post. version: '2' services: web: build: context: ./ dockerfile: deploy/web.docker volumes: - ./:/var/www ports: - "8080:80" links: - app How can I change permission (chmod ) /var/www automatically when docker-compose up -d --build ? (/questions/tagged/docker) (show questions tagged 'docker') docker (/questions/tagged/docker-compose) (show questions tagged 'docker-compose') docker-compose (/questions/tagged/devops) (show questions tagged 'devops') devops (/q/50325494) (Short permalink to this question) Share Share a link to this question Copy link (https://creativecommons.org/licenses/by-sa/4.0/) (The current license for this post: CC BY-SA 4.0) CC BY-SA 4.0 (/posts/50325494/edit) () Improve this question Follow (70:3:31e,16:07da812215d5c939,10:1740413509,16:02e65dbe51efe3fd,8:50325494,9b1dd93e9039f4b69afa788ac3a852557ed8e1ee38ac82a5891eae05cf605a8a) Follow this question to receive notifications (/posts/50325494/revisions) (show all edits to this post) edited (2021-05-31 02:03:39Z) May 31, 2021 at 2:03 (/users/1402846/pang) (Pang's user avatar) (/users/1402846/pang) Pang (reputation score 10,127) 10.1k (146 gold badges) 146 146 gold badges (86 silver badges) 86 86 silver badges (124 bronze badges) 124 124 bronze badges asked (2018-05-14 07:54:21Z) May 14, 2018 at 7:54 (/users/1233156/notalentgeek) (notalentgeek's user avatar) (/users/1233156/notalentgeek) notalentgeek notalentgeek (reputation score) 5,797 (12 gold badges) 12 12 gold badges (39 silver badges) 39 39 silver badges (58 bronze badges) 58 58 bronze badges (Use comments to ask for more information or suggest improvements. Avoid answering questions in comments.) Add a comment | (Expand to show all comments on this post) 3 Answers 3 Sorted by: (/questions/50325494/how-can-i-change-permission-of-mounted-volumes-in-docker-compose-yml-from-the-do?answertab=scoredesc#tab-top) Reset to default (scoredesc) Highest score (default) (trending) Trending (recent votes count more) (modifieddesc) Date modified (newest first) (createdasc) Date created (oldest first) This answer is useful (70:3:31e,16:446cca2f8c800484,10:1740413509,16:aa0c44d86636c10d,8:50325808,14950f49403d03b6de169981d6b82c4ebbfb6317d7c82db4c7b71bddbc9e42f3) 85 (This answer is not useful) (70:3:31e,16:a05bdd0f3664e347,10:1740413509,16:29b69037e243bf40,8:50325808,ffdd7e0df30dd5c3d27cf487c55d4b46b6789836989973596afad8ae9cac0de1) Save this answer. (Loading when this answer was accepted…) (/posts/50325808/timeline) Show activity on this post. When bind-mounting a directory from the host in a container, files and directories maintain the permissions they have on the host. This is by design: when using a bind-mount, you're giving the container access to existing files from the host, and Docker won't make modifications to those files; doing so would be very dangerous (for example, bind-mounting your home-directory would change file permissions of your host's home directory, possibly leading to your machine no longer being usable). To change permissions of those files, change their permissions on the host. You can find more information on this in another answer I posted on StackOverflow: (https://stackoverflow.com/a/29251160/1811501) https://stackoverflow.com/a/29251160/1811501 (/a/50325808) (Short permalink to this answer) Share Share a link to this answer Copy link (https://creativecommons.org/licenses/by-sa/4.0/) (The current license for this post: CC BY-SA 4.0) CC BY-SA 4.0 (/posts/50325808/edit) () Improve this answer Follow (70:3:31e,16:6f8fc2a0adabff7f,10:1740413509,16:9cb127eb2e25327d,8:50325808,c67d49dbcd8f43443b628905320877a26ab9bd1017822e7a7f91c16b4ac94a78) Follow this answer to receive notifications answered (2018-05-14 08:16:24Z) May 14, 2018 at 8:16 (/users/1811501/thajeztah) (thaJeztah's user avatar) (/users/1811501/thajeztah) thaJeztah thaJeztah (reputation score 29,087) 29.1k (9 gold badges) 9 9 gold badges (76 silver badges) 76 76 silver badges (92 bronze badges) 92 92 bronze badges 6 (number of 'useful comment' votes received) 27 Dude... That's exactly what Docker is currently doing to me... It changes the permissions and the paths become accessible only by root or the docker container user... The rest of the apps cannot use the directory anymore. I am looking for a way to set the permissions so that I can set the permissions back to the ones I wanted to have before they get changed... This is incredibly annoying and breaks stuff! – (/users/1281120/arturas-m) (4,369 reputation) Arturas M Commented (2020-11-23 19:05:55Z, License: CC BY-SA 4.0) Nov 23, 2020 at 19:05 How about if a VOLUME was created w/ docker volume create --driver local ... . Will it not be bind-mounted as well and if so, does one have control over file modes on the level of tools such as docker volume (as opposed to docker volume inspect ... && chmod ... )? – (/users/9164810/rookie099) (2,617 reputation) rookie099 Commented (2023-05-12 14:32:55Z, License: CC BY-SA 4.0) May 12, 2023 at 14:32 (number of 'useful comment' votes received) 1 @ArturasM docker itself does not change the permissions, but the container runs as root and modifies file-permissions (or creates files), those files may be owned by root . If those files are in a bind-mounted directory, then those files are modified. Run your container as a non-root user (which can be the UID/GID matching your user-account), or you can run the Docker Engine in "rootless mode" and set it up to re-map the root user to your account. (https://docs.docker.com/go/rootless/) docs.docker.com/go/rootless . Alternatively, use Docker Desktop, which converts permission (but comes with a performance overhead) – (/users/1811501/thajeztah) (29,087 reputation) thaJeztah Commented (2023-06-03 13:21:16Z, License: CC BY-SA 4.0) Jun 3, 2023 at 13:21 @rookie099 a VOLUME is effectively also a bind-mount, but the path that's mounted from is (by default) in a dedicated location on the daemon's host (inside /var/lib/docker ); those files should not be accessed directly from other tools. You can create a volume with a custom "source" location, but the situation is mostly the same (permissions in container === permissions "on the host"). – (/users/1811501/thajeztah) (29,087 reputation) thaJeztah Commented (2023-06-03 13:23:18Z, License: CC BY-SA 4.0) Jun 3, 2023 at 13:23 (number of 'useful comment' votes received) 1 I should add that recent versions of the Linux kernel added support for idmapped mounts, which could improve this in future (but it's not supported by all kernels, and support for it has not yet been implemented in all components used to run containers). – (/users/1811501/thajeztah) (29,087 reputation) thaJeztah Commented (2023-06-03 13:24:38Z, License: CC BY-SA 4.0) Jun 3, 2023 at 13:24 (Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”.) | (Expand to show all comments on this post) Show 1 more comment This answer is useful (70:3:31e,16:b9617227a08c54a6,10:1740413509,16:88e65721303c8468,8:50325601,6d231e174f7568e75f453dba95c227794ae0192ee96ca301f1faa6a0abefc23e) 21 (This answer is not useful) (70:3:31e,16:09c5974e61108d9d,10:1740413509,16:d96de70706835e0d,8:50325601,5335b920eb780a396f81b5e0b5badca09338ca13371a1c02a58a9ed537c04c75) Save this answer. (Loading when this answer was accepted…) (/posts/50325601/timeline) Show activity on this post. you can add the permissions after an extra column like: volumes: - ./:/var/www:ro #read only (/a/50325601) (Short permalink to this answer) Share Share a link to this answer Copy link (https://creativecommons.org/licenses/by-sa/4.0/) (The current license for this post: CC BY-SA 4.0) CC BY-SA 4.0 (/posts/50325601/edit) () Improve this answer Follow (70:3:31e,16:5aeb6bc2be587579,10:1740413509,16:c3c1576db803f7f2,8:50325601,d83df4ea86a5691b25929b6a1bb88a5be24709ddf0d7050262be9bccb8339c3d) Follow this answer to receive notifications (/posts/50325601/revisions) (show all edits to this post) edited (2022-03-29 19:21:39Z) Mar 29, 2022 at 19:21 (/users/5341247/superponey) (SuperPoney's user avatar) (/users/5341247/superponey) SuperPoney (reputation score) 670 (8 silver badges) 8 8 silver badges (26 bronze badges) 26 26 bronze badges answered (2018-05-14 08:02:43Z) May 14, 2018 at 8:02 (/users/1595977/edwin) (Edwin's user avatar) (/users/1595977/edwin) Edwin Edwin (reputation score) 2,278 (22 silver badges) 22 22 silver badges (26 bronze badges) 26 26 bronze badges 5 (number of 'useful comment' votes received) 10 Let say I want to have 777 or 750 like permission what would ro be? – (/users/1233156/notalentgeek) (5,797 reputation) notalentgeek Commented (2018-05-14 08:08:22Z, License: CC BY-SA 4.0) May 14, 2018 at 8:08 (number of 'useful comment' votes received) 2 check this out (https://en.wikipedia.org/wiki/Chmod) en.wikipedia.org/wiki/Chmod , especially the @Numerical permissions – (/users/1595977/edwin) (2,278 reputation) Edwin Commented (2018-05-14 08:09:39Z, License: CC BY-SA 4.0) May 14, 2018 at 8:09 (number of 'useful comment' votes received) 4 wait a second, you want to change the permissions of the files and folders of the mounted volume? I miss-read your question then, because that you can do it only on the host – (/users/1595977/edwin) (2,278 reputation) Edwin Commented (2018-05-14 08:20:05Z, License: CC BY-SA 4.0) May 14, 2018 at 8:20 (number of 'useful comment' votes received) 1 Just remember to delete the "//read only" part or you will get confusing errors about "invalid mode" when building – (/users/1334288/vidde) (91 reputation) Vidde Commented (2021-07-08 08:42:17Z, License: CC BY-SA 4.0) Jul 8, 2021 at 8:42 (this comment was edited 1 time) (number of 'useful comment' votes received) 2 This will mount a read-only filesystem, which isn't quite the same thing as changing permissions. It doesn't impact the flags set by chmod – (/users/9194976/cantankerousbullmoose) (512 reputation) CantankerousBullMoose Commented (2022-05-12 17:48:28Z, License: CC BY-SA 4.0) May 12, 2022 at 17:48 (Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”.) Add a comment | (Expand to show all comments on this post) This answer is useful (70:3:31e,16:16452cd1fab5447c,10:1740413509,16:be389978de68442d,8:65092449,cc90093f95420048e2f816833c7be0ef43437760589adea800cbad87ff5cb78d) 11 (This answer is not useful) (70:3:31e,16:e8eeb3bcb4c70cb6,10:1740413509,16:30edb06d3cee786c,8:65092449,f0c85a6d067e88958ae12585abf8b72ce7db2a8b4d3f95b48e436165127ff95e) Save this answer. (Loading when this answer was accepted…) (/posts/65092449/timeline) Show activity on this post. Actually this is a little more complicated, some better clarity would be required. If we mount the host folder folder_a into guest folder folder_b and the folder_b was already created, "chown"-ed and "chmod"-ed when the container image was created (Dockerfile), then folder_b defined permissions must take precedence from the guest perspective. This is what is happening on my boxes. As the guest user is not supposed to exist in the host an answer like "add the permissions to the host" is not very beautiful, it would mean "give write permissions to everybody". If folder_b was not already "prepared" for the mount upfront, but it is mounted "on the fly"; I have not found any way to change the permissions contextually. Trying to reason out loud: the docker daemon on the host does not know anything about the guest users. I am also curious if a chmod/chown on the fly with guest names is technically possible as an evolution of docker. My initial expectation is that the on the fly mount inherited the parent folder permissions ( if /mnt/a is owned by app_user, then mounting in /mnt/a/myMount would preserve app_user ownership to the child folder as well, however, the new mounted folder is owned by root in my tests ) From a security perspective, the guest operating the mounts should never mount its own secured/sensitive folders to the guests. It is generally assumed that if you give a volume to a guest, the guest must be able to execute any operation on it. However mounting "on the fly" produces a "root" owned folder inside the guest as root is the only user known to both guest and host. (/a/65092449) (Short permalink to this answer) Share Share a link to this answer Copy link (https://creativecommons.org/licenses/by-sa/4.0/) (The current license for this post: CC BY-SA 4.0) CC BY-SA 4.0 (/posts/65092449/edit) () Improve this answer Follow (70:3:31e,16:f8559027b24302b5,10:1740413509,16:730af9add32706e6,8:65092449,d4e8b19d8f7e6e0c4b85a24c46379502ceef99407038124c2d43b63fb6a9b524) Follow this answer to receive notifications (/posts/65092449/revisions) (show all edits to this post) edited (2020-12-11 16:44:03Z) Dec 11, 2020 at 16:44 answered (2020-12-01 14:28:59Z) Dec 1, 2020 at 14:28 (/users/9432999/mihai-ungureanu) (Mihai Ungureanu's user avatar) (/users/9432999/mihai-ungureanu) Mihai Ungureanu Mihai Ungureanu (reputation score) 111 (1 silver badge) 1 1 silver badge (4 bronze badges) 4 4 bronze badges 1 (number of 'useful comment' votes received) 1 You can pass the (current) user (and group) to docker, like it is described in this article: Running a Docker container as a non-root user -> (https://medium.com/redbubble/running-a-docker-container-as-a-non-root-user-7d2e00f8ee15) medium.com/redbubble/… – (/users/12383487/leonp5) (315 reputation) leonp5 Commented (2022-05-05 09:01:56Z, License: CC BY-SA 4.0) May 5, 2022 at 9:01 (Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”.) Add a comment | (Expand to show all comments on this post) (50325494) (false) () Your Answer (False) Reminder: Answers generated by artificial intelligence tools are not allowed on Stack Overflow. (/help/gen-ai-policy) Learn more (true) 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 (/help/how-to-answer) tips on writing great answers . Draft saved Draft discarded (8715abeb62cf6a9fe93de824cea527599cbf4e957f73c9d6615a4213f6b2728c) Sign up or (/users/login?ssrc=question_page&returnurl=https%3a%2f%2fstackoverflow.com%2fquestions%2f50325494%2fhow-can-i-change-permission-of-mounted-volumes-in-docker-compose-yml-from-the-do%23new-answer) log in Sign up using Google Sign up using Email and Password (false) (false) Submit Post as a guest Name () () Email Required, but never shown () () Post as a guest Name () () Email Required, but never shown () () Post Your Answer Discard By clicking “Post Your Answer”, you agree to our (https://stackoverflow.com/legal/terms-of-service/public) terms of service and acknowledge you have read our (https://stackoverflow.com/legal/privacy-policy) privacy policy .(1) Not the answer you're looking for? Browse other questions tagged (/questions/tagged/docker) (show questions tagged 'docker') docker (/questions/tagged/docker-compose) (show questions tagged 'docker-compose') docker-compose (/questions/tagged/devops) (show questions tagged 'devops') devops or (/questions/ask) ask your own question . The Overflow Blog (https://stackoverflow.blog/2025/02/20/research-roadmap-update-february-2025/?cb=1) Research roadmap update, February 2025 (https://stackoverflow.blog/2025/02/21/one-quality-every-engineering-manager-should-have-empathy/?cb=1) One quality every engineering manager should have? Empathy. Featured on Meta (Meta Stack Exchange) (https://meta.stackexchange.com/questions/406399/join-us-for-our-first-community-wide-ama-ask-me-anything-with-stack-overflow-s?cb=1) (Join us for our first community-wide AMA (Ask Me Anything) with Stack Overflow’s CEO (and a few others) on February 26, 2025) Join us for our first community-wide AMA (Ask Me Anything) with Stack... (Meta Stack Exchange) (https://meta.stackexchange.com/questions/406575/bigbird-and-frog-have-joined-us-as-community-managers?cb=1) bigbird and Frog have joined us as Community Managers (Meta Stack Overflow) (https://meta.stackoverflow.com/questions/421831/policy-generative-ai-e-g-chatgpt-is-banned?cb=1) Policy: Generative AI (e.g., ChatGPT) is banned (Meta Stack Overflow) (https://meta.stackoverflow.com/questions/433034/stacks-editor-development-and-testing?cb=1) Stacks Editor development and testing (Meta Stack Overflow) (https://meta.stackoverflow.com/questions/432989/is-it-better-to-redirect-users-who-attempt-to-perform-actions-they-cant-yet-tak?cb=1) (Is it better to redirect users who attempt to perform actions they can't yet take?) Is it better to redirect users who attempt to perform actions they can't yet... Linked (https://stackoverflow.com/q/29245216?lq=1) (Question score (upvotes - downvotes)) 90 (https://stackoverflow.com/questions/29245216/write-in-shared-volumes-docker?noredirect=1&lq=1) write in shared volumes docker (https://stackoverflow.com/q/74572753?lq=1) (Question score (upvotes - downvotes)) 2 (https://stackoverflow.com/questions/74572753/how-to-access-files-on-local-machine-when-running-spark-on-docker?noredirect=1&lq=1) How to access files on local machine when running Spark on Docker (https://stackoverflow.com/q/69047373?lq=1) (Question score (upvotes - downvotes)) 1 (https://stackoverflow.com/questions/69047373/why-do-owner-and-group-of-var-run-docker-sock-differ-between-host-and-container?noredirect=1&lq=1) Why do owner and group of /var/run/docker.sock differ between host and container? (https://stackoverflow.com/q/66801784?lq=1) (Question score (upvotes - downvotes)) 0 (https://stackoverflow.com/questions/66801784/docker-compose-cat-custom-conf-for-mariadb?noredirect=1&lq=1) docker-compose cat custom conf for mariadb? Related (https://stackoverflow.com/q/31706416?rq=3) (Question score (upvotes - downvotes)) 3 (https://stackoverflow.com/questions/31706416/permissions-issue-with-docker-volumes?rq=3) Permissions issue with Docker volumes (https://stackoverflow.com/q/40462189?rq=3) (Question score (upvotes - downvotes)) 224 (https://stackoverflow.com/questions/40462189/docker-compose-set-user-and-group-on-mounted-volume?rq=3) Docker-compose set user and group on mounted volume (https://stackoverflow.com/q/45214891?rq=3) (Question score (upvotes - downvotes)) 1 (https://stackoverflow.com/questions/45214891/how-to-set-volume-permission-in-docker-container-for-non-root-user?rq=3) How to set volume permission in docker container for non-root user (https://stackoverflow.com/q/49916803?rq=3) (Question score (upvotes - downvotes)) 11 (https://stackoverflow.com/questions/49916803/docker-compose-make-shared-volume-writable-permission-denied?rq=3) Docker Compose Make Shared Volume Writable Permission Denied (https://stackoverflow.com/q/53476535?rq=3) (Question score (upvotes - downvotes)) 2 (https://stackoverflow.com/questions/53476535/is-it-possible-to-set-a-umask-chmod-value-for-docker-volume?rq=3) Is it possible to set a umask/chmod value for docker volume? (https://stackoverflow.com/q/55784687?rq=3) (Question score (upvotes - downvotes)) 4 (https://stackoverflow.com/questions/55784687/how-to-specify-user-owning-volume-created-via-docker-compose-configuration?rq=3) How to specify user owning volume created via docker-compose configuration? (https://stackoverflow.com/q/55825478?rq=3) (Question score (upvotes - downvotes)) 6 (https://stackoverflow.com/questions/55825478/how-to-manage-permissions-for-a-volume-mounted-into-a-docker-container?rq=3) How to manage permissions for a volume mounted into a docker container? (https://stackoverflow.com/q/56144077?rq=3) (Question score (upvotes - downvotes)) 0 (https://stackoverflow.com/questions/56144077/docker-volume-create-set-permissions?rq=3) docker volume create - set permissions (https://stackoverflow.com/q/57591111?rq=3) (Question score (upvotes - downvotes)) 3 (https://stackoverflow.com/questions/57591111/file-permission-in-docker-container-with-volume-mount?rq=3) File permission in docker container with volume mount (https://stackoverflow.com/q/71748478?rq=3) (Question score (upvotes - downvotes)) 1 (https://stackoverflow.com/questions/71748478/set-user-permission-for-each-volume-within-docker-compose?rq=3) Set User Permission for each volume within docker-compose (https://stackexchange.com/questions?tab=hot) Hot Network Questions (Retrocomputing Stack Exchange) (https://retrocomputing.stackexchange.com/questions/31322/has-command-com-ever-been-compressed) Has command.com ever been compressed? (TeX - LaTeX Stack Exchange) (https://tex.stackexchange.com/questions/737768/emulating-itemize-using-tikz-so-i-can-draw-on-it) Emulating itemize using tikz, so I can draw on it (Electrical Engineering Stack Exchange) (https://electronics.stackexchange.com/questions/739785/are-there-any-other-ways-to-obtain-the-component) Are there any other ways to obtain the component? (Server Fault) (https://serverfault.com/questions/1173588/kvm-doesn-t-work-with-iptables) KVM doesn’t work with Iptables (Electrical Engineering Stack Exchange) (https://electronics.stackexchange.com/questions/739633/circuit-for-wiping-destroying-ic-on-a-smart-card) Circuit for wiping / destroying IC on a smart card (Information Security Stack Exchange) (https://security.stackexchange.com/questions/280646/how-to-protect-web-app-against-login-csrf-while-also-allowing-mobile-app-curl-to) How to protect web app against login CSRF while also allowing mobile app/curl to access REST API? (Academia Stack Exchange) (https://academia.stackexchange.com/questions/216974/same-work-lower-status-how-to-handle-a-demotion) Same work, lower status—how to handle a demotion? (Physics Stack Exchange) (https://physics.stackexchange.com/questions/843667/do-covariant-and-contravariant-indices-play-a-role-in-tensor-networks) Do Covariant and Contravariant Indices Play a Role in Tensor Networks? (Super User) (https://superuser.com/questions/1882243/how-can-i-know-if-my-windows-computer-is-connected-to-a-physical-display) How can I know if my Windows computer is connected to a physical display? (Physics Stack Exchange) (https://physics.stackexchange.com/questions/843733/how-exactly-does-energy-transformation-take-place) How exactly does energy transformation take place? (Science Fiction & Fantasy Stack Exchange) (https://scifi.stackexchange.com/questions/295117/is-there-a-reason-that-heinlein-omitted-let-there-be-light-from-the-past-thro) Is there a reason that Heinlein omitted "Let There Be Light" from "The Past Through Tomorrow" (Puzzling Stack Exchange) (https://puzzling.stackexchange.com/questions/130661/split-and-make-it-fit) Split and make it fit (Worldbuilding Stack Exchange) (https://worldbuilding.stackexchange.com/questions/264833/how-can-i-make-a-solar-system-wide-plague) How can I make a solar-system-wide plague? (Mathematica Stack Exchange) (https://mathematica.stackexchange.com/questions/311180/strong-dynamic-chromostereopsis-illusion) Strong dynamic chromostereopsis illusion (Skeptics Stack Exchange) (https://skeptics.stackexchange.com/questions/57716/did-the-national-institutes-of-health-spend-over-300-000-to-study-whether-quail) Did the National Institutes of Health spend over $300,000 to study whether quails got more frisky after being fed cocaine? (Biblical Hermeneutics Stack Exchange) (https://hermeneutics.stackexchange.com/questions/101734/how-do-we-interpret-herod-s-authority-in-mark-627) How do we interpret Herod’s authority in Mark 6:27? (Travel Stack Exchange) (https://travel.stackexchange.com/questions/193498/is-it-normal-to-get-an-apple-airtag-tracking-notification-on-a-train) Is it normal to get an Apple airtag tracking notification on a train? (Biology Stack Exchange) (https://biology.stackexchange.com/questions/116149/what-species-does-this-barnacle-shell-belong-to) What species does this barnacle shell belong to? (Mathematics Stack Exchange) (https://math.stackexchange.com/questions/5038935/a-recurrence-relation-for-polynomials-of-two-variables) A recurrence relation for polynomials of two variables (Raspberry Pi Stack Exchange) (https://raspberrypi.stackexchange.com/questions/150797/lost-eth0-device-instead-i-have-enxb827ebe00d07-how-to-fix-this) Lost eth0 device, instead I have "enxb827ebe00d07" How to fix this? (Code Golf Stack Exchange) (https://codegolf.stackexchange.com/questions/278355/tips-for-golfing-in-fortran) Tips for golfing in Fortran (Electrical Engineering Stack Exchange) (https://electronics.stackexchange.com/questions/739768/dc-voltage-drop-over-poe-with-and-without-load) DC Voltage drop over PoE with and without load (Aviation Stack Exchange) (https://aviation.stackexchange.com/questions/108044/whats-is-the-drag-on-a-sphere-as-a-function-of-speed) What's is the drag on a sphere as a function of speed? (Science Fiction & Fantasy Stack Exchange) (https://scifi.stackexchange.com/questions/295103/what-was-the-first-sff-movie-to-influence-later-books-in-the-same-franchise) What was the first SFF movie to influence later books in the same franchise? (/feeds/question/50325494) (Feed of this question and its answers) Question feed Subscribe to RSS Question feed To subscribe to this RSS feed, copy and paste this URL into your RSS reader. (https://stackoverflow.com/feeds/question/50325494) () lang-yaml (https://stackoverflow.com) (https://stackoverflow.com) Stack Overflow (/questions) Questions (/help) Help (https://chat.stackoverflow.com/?tab=site&host=stackoverflow.com) Chat (https://stackoverflow.co/) Products (https://stackoverflow.co/teams/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=footer&utm_content=teams) Teams (https://stackoverflow.co/advertising/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=footer&utm_content=advertising) Advertising (https://stackoverflow.co/advertising/employer-branding/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=footer&utm_content=talent) Talent (https://stackoverflow.co/) Company (https://stackoverflow.co/) About (https://stackoverflow.co/company/press/) Press (https://stackoverflow.co/company/work-here/) Work Here (https://stackoverflow.com/legal) Legal (https://stackoverflow.com/legal/privacy-policy) Privacy Policy (https://stackoverflow.com/legal/terms-of-service/public) Terms of Service (/contact) Contact Us Cookie Settings (https://stackoverflow.com/legal/cookie-policy) Cookie Policy (https://stackexchange.com) Stack Exchange Network (https://stackexchange.com/sites#technology) Technology (https://stackexchange.com/sites#culturerecreation) Culture & recreation (https://stackexchange.com/sites#lifearts) Life & arts (https://stackexchange.com/sites#science) Science (https://stackexchange.com/sites#professional) Professional (https://stackexchange.com/sites#business) Business (https://api.stackexchange.com/) API (https://data.stackexchange.com/) Data (https://stackoverflow.blog?blb=1) Blog (https://www.facebook.com/officialstackoverflow/) Facebook (https://twitter.com/stackoverflow) Twitter (https://linkedin.com/company/stack-overflow) LinkedIn (https://www.instagram.com/thestackoverflow) Instagram Site design / logo © 2025 Stack Exchange Inc; user contributions licensed under (https://stackoverflow.com/help/licensing) CC BY-SA . rev 2025.2.24.23018 By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our (https://stackoverflow.com/legal/cookie-policy) Cookie Policy . Accept all cookies Necessary cookies only Customize settings