docker-compose, run a script after container has started? - 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/47615751/docker-compose-run-a-script-after-container-has-started) (https://cdn.sstatic.net/Shared/stacks.css?v=bd2aba62c5a4) (https://cdn.sstatic.net/Sites/stackoverflow/primary.css?v=cc49ce762956) (Feed for question 'docker-compose, run a script after container has started?') (/feeds/question/47615751) (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%2f47615751%2fdocker-compose-run-a-script-after-container-has-started) Sign up or (https://stackoverflow.com/users/login?ssrc=site_switcher&returnurl=https%3a%2f%2fstackoverflow.com%2fquestions%2f47615751%2fdocker-compose-run-a-script-after-container-has-started) 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%2f47615751%2fdocker-compose-run-a-script-after-container-has-started) Log in (https://stackoverflow.com/users/signup?ssrc=head&returnurl=https%3a%2f%2fstackoverflow.com%2fquestions%2f47615751%2fdocker-compose-run-a-script-after-container-has-started) 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 shiny spring-security 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 axios pytorch terminal pip split mysqli cmd django-views encoding automation netbeans database-design collections hash data-binding ember.js build 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 module material-ui 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 constructor powerbi 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 path proxy 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 localization vuejs3 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 sequelize.js wso2 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 boolean apache-camel 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 sql-server-2008-r2 queue 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/47615751/docker-compose-run-a-script-after-container-has-started) docker-compose, run a script after container has started? (/questions/ask) Ask Question (2017-12-03 06:03:47Z) Asked 7 years, 2 months ago Modified (?lastactivity) (2025-01-26 08:33:16Z) 29 days ago (Viewed 424,387 times) Viewed 424k times This question shows research effort; it is useful and clear (70:3:31e,16:b01d1394eac920af,10:1740393669,16:676f0f0ca6ed4a8d,8:47615751,f9d727619f1f60bd9d7194f710aabea6e7543fc7ce38337f0618a67b96554af5) 190 (This question does not show any research effort; it is unclear or not useful) (70:3:31e,16:00d4bafd33e4c1bf,10:1740393669,16:10945490a42de897,8:47615751,da0808df3ddbda8c73932989fcea82e9b48a66c3487a51791371dfe196ee2b18) Save this question. (/posts/47615751/timeline) Show activity on this post. I have a service that I am bringing up through Rancher via docker-compose. The issue I am running into is that I need to set a password after the container has been deployed. The way rancher secrets work, is that I set my secret in and rancher will mount a volume on my container with a file containing my secret. I was hoping to be able to execute a script to grab that secret, and set it as a password on my config file. I don't believe I have a way to get that secret in through the Dockerfile as I don't want the secret to be in git, so I'm left looking at doing it via docker-compose. Does anyone know if this is possible? (/questions/tagged/docker) (show questions tagged 'docker') docker (/questions/tagged/docker-compose) (show questions tagged 'docker-compose') docker-compose (/questions/tagged/dockerfile) (show questions tagged 'dockerfile') dockerfile (/questions/tagged/rancher) (show questions tagged 'rancher') rancher (/q/47615751) (Short permalink to this question) Share Share a link to this question Copy link (https://creativecommons.org/licenses/by-sa/3.0/) (The current license for this post: CC BY-SA 3.0) CC BY-SA 3.0 (/posts/47615751/edit) () Improve this question Follow (70:3:31e,16:bb748dfeebff83b8,10:1740393669,16:ae0338caf14860a5,8:47615751,2627a3cbc3db5b8b9036c25c8996a98b7899cc4b755fad4f3d7713ade2e1cd3c) Follow this question to receive notifications asked (2017-12-03 06:03:47Z) Dec 3, 2017 at 6:03 (/users/6726990/blooze) (Blooze's user avatar) (/users/6726990/blooze) Blooze Blooze (reputation score) 2,267 (4 gold badges) 4 4 gold badges (18 silver badges) 18 18 silver badges (19 bronze badges) 19 19 bronze badges 3 Absolutely, that's a fairly normal way of setting secrets. Just add the relevant shell script as (or to) your CMD or ENTRYPOINT. – (/users/3195526/paul-hicks) (14,009 reputation) Paul Hicks Commented (2017-12-03 06:06:38Z, License: CC BY-SA 3.0) Dec 3, 2017 at 6:06 to have access to secret without expose in Dockerfile, you can use .env file with docker-compose : (https://docs.docker.com/compose/environment-variables/) docs.docker.com/compose/environment-variables – (/users/6614155/bcag2) (2,439 reputation) bcag2 Commented (2021-08-03 16:33:12Z, License: CC BY-SA 4.0) Aug 3, 2021 at 16:33 (number of 'useful comment' votes received) 1 Hi. This is specific problem. The way to use a separate service as a set UP service is working solution. But often images provide you some sort of the 'hooks' that can be used. Like (https://github.com/bitnami/bitnami-docker-kafka/blob/master/3.1/debian-10/rootfs/opt/bitnami/scripts/libkafka.sh#L768) here for kafka. You need just put a scripts to the "docker-entrypoint-initdb.d" to run some sort of set up. – (/users/3549038/stopanko) (336 reputation) stopanko Commented (2022-04-07 17:42:50Z, License: CC BY-SA 4.0) Apr 7, 2022 at 17:42 (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) 6 Answers 6 Sorted by: (/questions/47615751/docker-compose-run-a-script-after-container-has-started?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:41f058b8f6468cff,10:1740393669,16:d4651c5b493d556c,8:64153124,934b983d3331c2a036f87048b6ea08e7519cc937a1571cd21ef996e4b7f994cc) 115 (This answer is not useful) (70:3:31e,16:1994879f5c0efac0,10:1740393669,16:d390ea2ec695ec35,8:64153124,3e3a5149c71c7fcddb52a32611068eefea2883c2135c11fd818157c3981accb7) Save this answer. (Loading when this answer was accepted…) (/posts/64153124/timeline) Show activity on this post. This is the way I use for calling a script after a container is started without overriding the entrypoint. In my example, I used it for initializing the replicaset of my local MongoDB services: mongo: image: mongo:4.2.8 hostname: mongo container_name: mongodb entrypoint: ["/usr/bin/mongod" ,"--bind_ip_all" ,"--replSet" ,"rs0" ] ports: - 27017 :27017 mongosetup: image: mongo:4.2.8 depends_on: - mongo restart: "no" entrypoint: [ "bash" , "-c" , "sleep 10 && mongo --host mongo:27017 --eval 'rs.initiate()'" ] In the first part, I simply launch my service (mongo) The second service use a "bash" entry point AND a restart: no <= important I also use a depends_on between service and setup service for manage the launch order. (/a/64153124) (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/64153124/edit) () Improve this answer Follow (70:3:31e,16:212bf3e20bb261fe,10:1740393669,16:d8c5a391da3f894a,8:64153124,9ccc725b146ab4b2d579bcc340812e0efd5884e9b8c5ca36bbbbf489eb0cee6e) Follow this answer to receive notifications (/posts/64153124/revisions) (show all edits to this post) edited (2021-02-15 22:30:57Z) Feb 15, 2021 at 22:30 (/users/2831606/redgeoff) (redgeoff's user avatar) (/users/2831606/redgeoff) redgeoff (reputation score) 3,341 (1 gold badge) 1 1 gold badge (28 silver badges) 28 28 silver badges (41 bronze badges) 41 41 bronze badges answered (2020-10-01 10:02:42Z) Oct 1, 2020 at 10:02 (/users/11125845/gibson-lunaziz) (Gibson Lunaziz's user avatar) (/users/11125845/gibson-lunaziz) Gibson Lunaziz Gibson Lunaziz (reputation score) 1,173 (1 gold badge) 1 1 gold badge (7 silver badges) 7 7 silver badges (8 bronze badges) 8 8 bronze badges 5 (number of 'useful comment' votes received) 5 This approach seems interesting but for me raises some questions. First, why use the mongo image for the mongosetup container? Will just any image do? Or is it important that it should be the mongo one? Second, you say that setting restart: no is important, but why is that? So that setup does not get executed multiple times? Last, I see sleep 10 ? Is that to give mongo time to initialize? Seems tricky to use sleep for that... – (/users/286685/stijn-de-witt) (42,114 reputation) Stijn de Witt Commented (2022-04-06 07:45:31Z, License: CC BY-SA 4.0) Apr 6, 2022 at 7:45 (number of 'useful comment' votes received) 1 @StijndeWitt 1. "Why use mongo image?" because the command mongo --host mongo:27017 --eval 'rs.initiate()' which is the 4th element of mongosetup.entrypoint property in the above docker-compose, uses mongo which is a cli program (mongosh also can be used as a newer alternative) and this program is pre-installed on mongo images. – (/users/2605781/gandalf) (3,257 reputation) Gandalf Commented (2022-06-25 14:43:34Z, License: CC BY-SA 4.0) Jun 25, 2022 at 14:43 (this comment was edited 3 times) (number of 'useful comment' votes received) 1 @StijndeWitt 2. "you say that setting restart: no is important, but why is that?" because as the name for this container suggests, this container is for setting up replica set for mongo, which means just running the mongo --host mongo:27017 --eval 'rs.initiate()' either from a container that can access the mongo container using mongo:27017 (both container must be on the same network, like mongosetup and mongo containers are, in this – (/users/2605781/gandalf) (3,257 reputation) Gandalf Commented (2022-06-25 14:44:12Z, License: CC BY-SA 4.0) Jun 25, 2022 at 14:44 (this comment was edited 2 times) (number of 'useful comment' votes received) 1 @StijndeWitt setup, the string mongo in mongosetup container, maps to the IP of mongo container) or from the same container you can run mongo --eval 'rs.initiate()' since in this example the first approach is taken, and as explained the mongo --host mongo:27017 --eval 'rs.initiate()' must get executed at least once(preferably only once). hence restart: "no" is set, to let the container shut down after it has run the command successfully. – (/users/2605781/gandalf) (3,257 reputation) Gandalf Commented (2022-06-25 14:44:29Z, License: CC BY-SA 4.0) Jun 25, 2022 at 14:44 (this comment was edited 1 time) (number of 'useful comment' votes received) 1 @StijndeWitt 3. "I see sleep 10? Is that to give mongo time to initialize?" yes, it waits for 10 seconds before running the command, because the mongo daemon in the mongo container, must be up and running in order for the command to run successfully – (/users/2605781/gandalf) (3,257 reputation) Gandalf Commented (2022-06-25 14:44:38Z, License: CC BY-SA 4.0) Jun 25, 2022 at 14:44 (this comment was edited 2 times) (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:d3b1c3385378d43d,10:1740393669,16:80b5b74c0d4f6262,8:47629959,ea462b30067c4a8f4073db44cb697b9b4ac5872f8851f1113f7df998197719e7) 75 (This answer is not useful) (70:3:31e,16:7d0f0df76043b162,10:1740393669,16:5a69c673a060dfce,8:47629959,42f9aa07d59ab1f19779cb9836d14be42a241ace0bdc0d1dd7ae2982f4ec8ccc) Save this answer. (Loading when this answer was accepted…) (/posts/47629959/timeline) Show activity on this post. The trick is to overwrite the compose COMMAND to perform whatever init action you need before calling the original command. Add a script in your image that will perform the init work that you want like set password, change internal config files, etc. Let's call it init.sh . You add it to your image. Dockerfile: FROM: sourceimage:tag COPY init.sh /usr/local/bin/ ENTRYPOINT [] The above overrides whatever ENTRYPOINT is defined in the sourceimage . That's to make this example simpler. Make sure you understand what the ENTRYPOINT is doing in the Dockerfile from the sourceimage and call it in the command: of the docker-compose.yml file. docker-compose.yml: services: myservice: image: something:tag ... command: sh -c "/usr/local/bin/init.sh && exec myexecutable" It's important to use exec before calling the main command. That will install the command as the first process (PID1) which will make it receive signals like STOP, KILL (Ctrl-C on keyboard) or HUP. (/a/47629959) (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/47629959/edit) () Improve this answer Follow (70:3:31e,16:23264072813ad50c,10:1740393669,16:37df73a51dbe1b81,8:47629959,94a4431b69e99b9699f05cb397e166f66b1fdd63482709e302ce437c0d81edb0) Follow this answer to receive notifications (/posts/47629959/revisions) (show all edits to this post) edited (2020-05-05 02:39:27Z) May 5, 2020 at 2:39 (/users/1042380/yu%d1%8fi) (yuяi's user avatar) (/users/1042380/yu%d1%8fi) yuяi (reputation score) 2,725 (1 gold badge) 1 1 gold badge (26 silver badges) 26 26 silver badges (46 bronze badges) 46 46 bronze badges answered (2017-12-04 09:17:59Z) Dec 4, 2017 at 9:17 (/users/1556338/bernard) (Bernard's user avatar) (/users/1556338/bernard) Bernard Bernard (reputation score 17,281) 17.3k (13 gold badges) 13 13 gold badges (67 silver badges) 67 67 silver badges (69 bronze badges) 69 69 bronze badges 10 (number of 'useful comment' votes received) 5 executing this causes /usr/local/bin/docker-entrypoint.sh: line 172: /usr/local/bin/init.sh: No such file or directory – (/users/4520965/james-jordan-taylor) (1,718 reputation) James Jordan Taylor Commented (2018-08-14 00:28:09Z, License: CC BY-SA 4.0) Aug 14, 2018 at 0:28 (this comment was edited 1 time) (number of 'useful comment' votes received) 3 Additionally, removing the first part of the command causes the error exec: not found – (/users/4520965/james-jordan-taylor) (1,718 reputation) James Jordan Taylor Commented (2018-08-14 00:31:05Z, License: CC BY-SA 4.0) Aug 14, 2018 at 0:31 (number of 'useful comment' votes received) 3 @BurhanAli I've updated the answer to explicitly call the "shell -c". Also, there are many different combinations of ENTRYPOINT /CMD (Dockerfile) and entrypoint: /command: (docker compose) which can override each other. To keep this answer concise, I reset the ENTRYPOINT so that it doesn't override command . – (/users/1556338/bernard) (17,281 reputation) Bernard Commented (2020-02-20 23:31:06Z, License: CC BY-SA 4.0) Feb 20, 2020 at 23:31 (number of 'useful comment' votes received) 1 @MurtazaHaji. In your case the line would be command: sh -c "/usr/local/bin/init.sh && exec redid-server --deamonize yes – (/users/1556338/bernard) (17,281 reputation) Bernard Commented (2021-06-07 11:25:04Z, License: CC BY-SA 4.0) Jun 7, 2021 at 11:25 (this comment was edited 1 time) (number of 'useful comment' votes received) 3 @aderchox That's correct, command will override the CMD instruction in the image. However, the final startup action is obtained by combining ENTRYPOINT and CMD . So if ENTRYPOINT is for instance ["echo"] , you can set CMD to "hello" and this will print "hello". I believe this was done historically to allow different arguments to be specified easily. ENTRYPOINT contains the main executable and CMD contains the arguments passed to the executable. You can also set ENTRYPOINT to an empty array so that CMD or command contains the full startup action line, like we do above. – (/users/1556338/bernard) (17,281 reputation) Bernard Commented (2021-10-31 11:10:25Z, License: CC BY-SA 4.0) Oct 31, 2021 at 11:10 (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 5 more comments This answer is useful (70:3:31e,16:2fd1faacfab4451f,10:1740393669,16:9ff47c869759ce7f,8:66994812,e2ae74f40d32dc5a3a15ba5a057cee7c63561871d17d3310d4467e9079623f4c) 31 (This answer is not useful) (70:3:31e,16:94a29a7f07fae455,10:1740393669,16:a27481842e82b9e8,8:66994812,eea432f4528c8aa0924be065e2fdfdff83113c49bcde882c7634a27591fb6d21) Save this answer. (Loading when this answer was accepted…) (/posts/66994812/timeline) Show activity on this post. You can also use volumes to do this: services: example: image: volume: ./init.sh:/init.sh entrypoint: sh -c "/init.sh" Note that this will mount init.sh to the container, not copy it (if that matters, usually it doesn't). Basically processes within the container can modify init.sh and it would modify the file as it exists in your actual computer. (/a/66994812) (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/66994812/edit) () Improve this answer Follow (70:3:31e,16:da70a8bc05bbd23c,10:1740393669,16:bb18cbe700417fd4,8:66994812,f4dff0efaee9df134106c354c460446d003420181f9d2cee8e9816ab483ac13a) Follow this answer to receive notifications (/posts/66994812/revisions) (show all edits to this post) edited (2021-04-08 19:11:20Z) Apr 8, 2021 at 19:11 answered (2021-04-07 22:13:49Z) Apr 7, 2021 at 22:13 (/users/4021308/asad-ullah-khan) (Asad-ullah Khan's user avatar) (/users/4021308/asad-ullah-khan) Asad-ullah Khan Asad-ullah Khan (reputation score) 1,853 (21 silver badges) 21 21 silver badges (25 bronze badges) 25 25 bronze badges 5 (number of 'useful comment' votes received) 2 Got it! I needed entrypoint: sh -c "sh init.sh" for it to work properly – (/users/2805387/fullstackchris) (1,502 reputation) fullStackChris Commented (2022-05-25 19:30:15Z, License: CC BY-SA 4.0) May 25, 2022 at 19:30 (number of 'useful comment' votes received) 2 interesting, looks like you mounted it to ./init.sh instead of /init.sh ? seeing sh twice feels icky 😅 – (/users/4021308/asad-ullah-khan) (1,853 reputation) Asad-ullah Khan Commented (2022-05-25 23:50:01Z, License: CC BY-SA 4.0) May 25, 2022 at 23:50 (number of 'useful comment' votes received) 1 using entrypoint: sh -c "sh /init.sh" resolve the issue sh: /init.sh: Permission denied – (/users/3129401/mag) (171 reputation) mag Commented (2023-05-16 13:06:23Z, License: CC BY-SA 4.0) May 16, 2023 at 13:06 how to solve "Permission denied" problem? – (/users/7952365/rgaponov) (143 reputation) rgaponov Commented (2023-07-26 19:20:30Z, License: CC BY-SA 4.0) Jul 26, 2023 at 19:20 you will need to be more specific, but my guess is that the docker process does not have access to init.sh on your local computer, so you get this error. either copy the init.sh as suggested by (https://stackoverflow.com/a/47629959/4021308) stackoverflow.com/a/47629959/4021308 or move init.sh to somewhere docker would be allowed to access. i would NOT recommend running docker in --privileged mode ((https://stackoverflow.com/a/35620590/4021308) stackoverflow.com/a/35620590/4021308 ) – (/users/4021308/asad-ullah-khan) (1,853 reputation) Asad-ullah Khan Commented (2023-07-26 19:46:48Z, License: CC BY-SA 4.0) Jul 26, 2023 at 19:46 (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:3ad1cddc910e43ae,10:1740393669,16:099c5db4efcc7a15,8:79258316,a976678b5086fbeae78408cd3e54a7f2b5f09f05a5b6b73e5d4db53694519337) 10 (This answer is not useful) (70:3:31e,16:4c3b0e37a6f6508e,10:1740393669,16:ae3b306b44fa64ac,8:79258316,7db0d71da2881e1b7a851e9835d7dfe0b9cb7d6e75a2506c104e6d2880931664) Save this answer. (Loading when this answer was accepted…) (/posts/79258316/timeline) Show activity on this post. Since Compose 2.30 you may use the (https://docs.docker.com/compose/how-tos/lifecycle/#post-start-hooks) post_start lifecycle hook . For your specific usecase, the docker-compose.yml could look like this: version: '3.8' services: my_service: image: my_image volumes: - /run/secrets:/run/secrets # Mount Rancher secrets post_start: - command: | PASSWORD=$(cat /run/secrets/my_secret_file) && sed -i "s/placeholder_password/$PASSWORD/" /path/to/config.file (/a/79258316) (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/79258316/edit) () Improve this answer Follow (70:3:31e,16:9bd28ea507bbabdb,10:1740393669,16:50994d7a0e43e1f7,8:79258316,1e3127b8434169fd9b1d5bce93109f6e4bf6b40aa972f47995701589bd854800) Follow this answer to receive notifications answered (2024-12-06 14:23:42Z) Dec 6, 2024 at 14:23 (/users/1901362/lutangar) (lutangar's user avatar) (/users/1901362/lutangar) lutangar lutangar (reputation score) 123 (1 silver badge) 1 1 silver badge (5 bronze badges) 5 5 bronze badges 1 Note that "The hook execution timing is not assured during the execution of the container's entrypoint." from (https://docs.docker.com/compose/how-tos/lifecycle/#post-start-hooks) docs.docker.com/compose/how-tos/lifecycle/#post-start-hooks – (/users/12576620/n0099) (1,393 reputation) n0099 Commented (2025-01-06 11:47:19Z, License: CC BY-SA 4.0) Jan 6 at 11:47 (this comment was edited 2 times) (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:b794df5ef85e69f8,10:1740393669,16:42df7deafb000ef0,8:47615848,4741b9a5262602addee36b74a723145e5b6341baa942eabacdf3ee2a7c41ccd1) 2 (This answer is not useful) (70:3:31e,16:f73a36c7581a114e,10:1740393669,16:710db3df75460d1b,8:47615848,64f4dbd226cafbc23c2d8351524f6fd8813ffae80bc67e86866a92401dd9391d) Save this answer. (Loading when this answer was accepted…) (/posts/47615848/timeline) Show activity on this post. docker-compose specify how to launch containers, not how to modify an existing running container. The (http://rancher.com/docs/rancher/latest/en/cattle/secrets/#adding-secrets-using-rancher-cli) Rancher documentation mentions that, for default usage of secrets, you can reference the secret by name in the secrets array in the docker-compose.yml . The target filename will be the same name as the name of the secret.By default, the target filename will be created as User ID and Group ID 0, and File Mode of 0444.Setting external to true in the secrets part will make sure it knows the secret has already been created. Example of a basic docker-compose.yml : version: '2' services: web: image: sdelements/lets-chat stdin_open: true secrets: - name-of-secret labels: io.rancher.container.pull_image: always secrets: name-of-secret: external: true As illustrated in "(https://staxmanade.com/2016/09/how-to-update-a-single-running-docker-compose-container/) How to Update a Single Running docker-compose Container ", updating a container would involve a "build, kill, and up" sequence. docker-compose up -d --no-deps --build (/a/47615848) (Short permalink to this answer) Share Share a link to this answer Copy link (https://creativecommons.org/licenses/by-sa/3.0/) (The current license for this post: CC BY-SA 3.0) CC BY-SA 3.0 (/posts/47615848/edit) () Improve this answer Follow (70:3:31e,16:eb96911d01d6ca1a,10:1740393669,16:6b988ee2e260b162,8:47615848,9c5080f6a9b083d9b3ef63ef1cb3438bc55ba75399b136ce5245a12e4ee77ae2) Follow this answer to receive notifications answered (2017-12-03 06:19:24Z) Dec 3, 2017 at 6:19 (/users/6309/vonc) (VonC's user avatar) (/users/6309/vonc) VonC VonC (reputation score 1,326,862) 1.3m (563 gold badges) 563 563 gold badges (4.7k silver badges) 4.7k 4.7k silver badges (5.6k bronze badges) 5.6k 5.6k bronze badges 0 (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:a47e3f51e2ab9d65,10:1740393669,16:364e737aecd9655f,8:79333020,43844531b5c5b63cdf0e8486ce0b69abb2643c0a01f283e561ab760aa2d468b7) 0 (This answer is not useful) (70:3:31e,16:6d39c1556e8c0e41,10:1740393669,16:8e9123f7a3cb84ec,8:79333020,ca1d4e89dcd4e55258e1f6b23570fc4ba51ab982240850e4b28458ff4af4aca1) Save this answer. (Loading when this answer was accepted…) (/posts/79333020/timeline) Show activity on this post. (https://superuser.com/questions/1054678/can-we-execute-a-script-as-root-during-docker-container-startup/1869399#1869399) Can we execute a script as root during docker container startup? COPY <<'DASH' /etc/rc.local set -x printenv DASH ENTRYPOINT ["dash", "-xc", ". /etc/rc.local && exec \"$@\"", "$@"] CMD [] Explain: The file /etc/rc.local is a (https://unix.stackexchange.com/questions/49626/purpose-and-typical-usage-of-etc-rc-local) historical filename for putting scripts that will be executed by (https://unix.stackexchange.com/questions/5877/what-are-the-pros-cons-of-upstart-and-systemd) pre-systemd-era -daemon (https://en.wikipedia.org/wiki/sysvinit) SysV init during the system boot. Another similar path for this purpose is (https://unix.stackexchange.com/questions/3537/etc-rc-d-vs-etc-init-d) /etc/init.d/* . Here we just take this filename for convention as in docker container there's no init/systemd daemon by default and the ENTRYPOINT is the (https://news.ycombinator.com/item?id=8916785) pid 1 . The original value of image ENTRYPOINT can be found in its (https://docs.docker.com/reference/dockerfile/#ENTRYPOINT) Dockerfile or get overrided by (https://docs.docker.com/reference/compose-file/services/#entrypoint) compose.yaml . And setting a new ENTRYPOINT will reset the original CMD (https://docs.docker.com/reference/dockerfile/#understand-how-cmd-and-entrypoint-interact) to empty string : If CMD is defined from the base image, setting ENTRYPOINT will reset CMD to an empty value. In this scenario, CMD must be defined in the current image to have a value. so we have to copy the value of CMD from the (https://docs.docker.com/reference/dockerfile/#CMD) Dockerfile of original image or (https://docs.docker.com/reference/compose-file/services/#command) compose.yaml if get overrided in it. sh -xc 'echo "$@"' 1 2 3 is a way to (https://unix.stackexchange.com/questions/144514/add-arguments-to-bash-c/144519#144519) pass shell arguments into sh -c , and this example shall run echo 1 2 3 that can be verified by (https://gist.github.com/mohanpedala/1e2ff5661761d3abd0385e8223e16425) set -x . dash is yet another (https://askubuntu.com/questions/976485/what-is-the-point-of-sh-being-linked-to-dash/976504#976504) implement of sh ell that's (https://unix.stackexchange.com/questions/148035/is-dash-or-some-other-shell-faster-than-bash) faster than bash and being used as the (https://wiki.ubuntu.com/DashAsBinSh) default /bin/sh in Debian. If you use some (https://mywiki.wooledge.org/Bashism) bashism (https://askubuntu.com/questions/1277922/what-are-syntax-differences-between-bash-and-dash) features that in /etc/rc.local , feel free to replace it with bash or other shell implements. $@ is the value of all shell arguments except the first one like $argv[0] or (https://unix.stackexchange.com/questions/412707/why-0-is-not-a-positional-parameter) $0 which is the value being passed to (https://news.ycombinator.com/item?id=41434315) execv . In the shell env of ENTRYPOINT when a container is created, its $@ will be the value of (https://docs.docker.com/reference/dockerfile/#understand-how-cmd-and-entrypoint-interact) Dockerfile CMD , so we could pass the value CMD from outer shell into the inner that created by sh -c 'echo "$@"' $@ . The value of ENTRYPOINT and CMD in (https://docs.docker.com/reference/dockerfile/#shell-and-exec-form) Dockerfile or (https://docs.docker.com/reference/compose-file/services/#entrypoint) compose.yaml must be written in exec form for removing the (https://stackoverflow.com/questions/47904974/what-are-shell-form-and-exec-form) extra ["sh", "-c"] being prepend to the value when using shell form. Using docker image inspect - \ | jq '.[0].Config | with_entries(select([.key] | inside(["Cmd", "Entrypoint"])))' to view the value of ENTRYPOINT or CMD of a built image for compose service that can be found in (https://docs.docker.com/reference/cli/docker/image/ls/) docker images -a . Whereas the should be the value of (https://docs.docker.com/compose/how-tos/environment-variables/envvars/#compose_project_name) $COMPOSE_PROJECT_NAME that defaults the (https://en.wikipedia.org/wiki/Dirname) dirname(1) of the path of compose.yaml . The (https://en.wikipedia.org/wiki/Jq_(programming_language)) jq expression just like (https://stackoverflow.com/questions/29518137/jq-selecting-a-subset-of-keys-from-an-object/46293052#46293052) _.pick() in (https://lodash.com/docs/4.17.15#pick) lodash . Double-quoting $@ as "$@" will prevent shell (https://mywiki.wooledge.org/WordSplitting) IFS= (https://www.shellcheck.net/wiki/SC2086) word splitting for passing the original Dockerfile CMD as is into $1 of sh -c . This can be verified by (https://stackoverflow.com/questions/12314451/accessing-bash-command-line-args-vs/12316565#12316565) for word in "$@"; do echo "$word"; done in /etc/rc.local "$@" and can fix some issues like (https://stackoverflow.com/questions/64392543/nginx-invalid-option-off-and-entrypoint-sh-permission-denied/78606672#78606672) nginx: invalid option: "off" with the offical docker image (https://github.com/nginxinc/docker-nginx/blob/f227279d7b5c8ae8f99d29ed61f0da4c9ac0a404/entrypoint/docker-entrypoint.sh#L47) nginx . Prepend (https://en.wikipedia.org/wiki/Exec_(system_call)) exec(1p) before "$@" will replace the ENTRYPOINT process dash with the first one in $@ array. This is a (https://unix.stackexchange.com/questions/466999/what-does-exec-do) common pattern with (https://stackoverflow.com/questions/32255814/what-purpose-does-using-exec-in-docker-entrypoint-scripts-serve/) docker entrypoint to allow passing (https://en.wikipedia.org/wiki/Signal_(IPC)) UNIX signal to the proper process as only the topmost init process, that either to be the ENTRYPOINT or be replaced by exec in ENTRYPOINT , can recive UNIX signal from docker daemon. Or you will have to write a signal processor with trap in the (https://stackoverflow.com/questions/68523106/docker-bash-shell-script-does-not-catch-sigint-or-sigterm) entrypoint shell or with (https://en.wikipedia.org/wiki/C_signal_handling) signal() in the entrypoint process. Most ENTRYPOINT shell in well-formed Dockerfile has already an exec "$@" in the end so the pid 1 will be replaced by twice, and this exec can still act as a safety net. The dot . before /etc/rc.local is the what (https://stackoverflow.com/questions/20094271/using-dot-or-source-while-calling-another-script-what-is-the-difference) source alias to in bashism. Comparing to (https://superuser.com/questions/176783/what-is-the-difference-between-executing-a-bash-script-vs-sourcing-it) execute the /etc/rc.local directly without prepending . , sourcing it won't require (https://unix.stackexchange.com/questions/291404/why-does-bashs-source-not-need-the-execution-bit) chmod +x and can pass (https://stackoverflow.com/questions/16618071/can-i-export-a-variable-to-the-environment-from-a-bash-script-without-sourcing-i) export ed enviornment variables into the dash as entrypoint. Taking the offical docker image (https://hub.docker.com/_/php) php as a example: We can find its original (https://github.com/docker-library/php/blob/75a0c3c716c3d4f64800ccf098142ecd751197f8/8.3/bookworm/fpm/Dockerfile#L223) ENTRYPOINT is (https://github.com/docker-library/php/blob/75a0c3c716c3d4f64800ccf098142ecd751197f8/8.3/bookworm/fpm/docker-php-entrypoint) docker-php-entrypoint and original (https://github.com/docker-library/php/blob/75a0c3c716c3d4f64800ccf098142ecd751197f8/8.3/bookworm/fpm/Dockerfile#L275) CMD is php-fpm , so we should fill them with: ENTRYPOINT ["dash", "-xc", ". /etc/rc.local && exec docker-php-entrypoint \"$@\"", "$@"] CMD ["php-fpm"] If the order of executing script before or after the entrypoint get started is not important for you, also try the much simpler (https://stackoverflow.com/questions/47615751/docker-compose-run-a-script-after-container-has-started/79258316#79258316) post-start lifecycle hook in Docker Compose. (/a/79333020) (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/79333020/edit) () Improve this answer Follow (70:3:31e,16:e1ab5aad9285c307,10:1740393669,16:30f6e92ca91d4721,8:79333020,49e159b5ec3e44700701149efe96e77e692062bcb5f661833302275e8e33ec36) Follow this answer to receive notifications (/posts/79333020/revisions) (show all edits to this post) edited (2025-01-26 08:33:16Z) Jan 26 at 8:33 (/users/13302/marc-s) (marc_s's user avatar) (/users/13302/marc-s) marc_s (reputation score 754,993) 755k (184 gold badges) 184 184 gold badges (1.4k silver badges) 1.4k 1.4k silver badges (1.5k bronze badges) 1.5k 1.5k bronze badges answered (2025-01-06 12:25:28Z) Jan 6 at 12:25 (/users/12576620/n0099) (n0099's user avatar) (/users/12576620/n0099) n0099 n0099 (reputation score) 1,393 (1 gold badge) 1 1 gold badge (12 silver badges) 12 12 silver badges (19 bronze badges) 19 19 bronze badges (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) (47615751) (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%2f47615751%2fdocker-compose-run-a-script-after-container-has-started%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/dockerfile) (show questions tagged 'dockerfile') dockerfile (/questions/tagged/rancher) (show questions tagged 'rancher') rancher 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/16618071?lq=1) (Question score (upvotes - downvotes)) 492 (https://stackoverflow.com/questions/16618071/can-i-export-a-variable-to-the-environment-from-a-bash-script-without-sourcing-i?noredirect=1&lq=1) Can I export a variable to the environment from a Bash script without sourcing it? (https://stackoverflow.com/q/12314451?lq=1) (Question score (upvotes - downvotes)) 447 (https://stackoverflow.com/questions/12314451/accessing-bash-command-line-args-vs?noredirect=1&lq=1) Accessing bash command line args $@ vs $* (https://stackoverflow.com/q/20094271?lq=1) (Question score (upvotes - downvotes)) 125 (https://stackoverflow.com/questions/20094271/using-dot-or-source-while-calling-another-script-what-is-the-difference?noredirect=1&lq=1) Using dot or "source" while calling another script - what is the difference? (https://stackoverflow.com/q/29518137?lq=1) (Question score (upvotes - downvotes)) 49 (https://stackoverflow.com/questions/29518137/jq-selecting-a-subset-of-keys-from-an-object?noredirect=1&lq=1) jq: selecting a subset of keys from an object (https://stackoverflow.com/q/32255814?lq=1) (Question score (upvotes - downvotes)) 61 (https://stackoverflow.com/questions/32255814/what-purpose-does-using-exec-in-docker-entrypoint-scripts-serve?noredirect=1&lq=1) What purpose does using exec in docker entrypoint scripts serve? (https://stackoverflow.com/q/47904974?lq=1) (Question score (upvotes - downvotes)) 43 (https://stackoverflow.com/questions/47904974/what-are-shell-form-and-exec-form?noredirect=1&lq=1) What are shell form and exec form? (https://stackoverflow.com/q/35617912?lq=1) (Question score (upvotes - downvotes)) 28 (https://stackoverflow.com/questions/35617912/why-does-docker-container-prompt-permission-denied?noredirect=1&lq=1) Why does docker container prompt "Permission denied"? (https://stackoverflow.com/q/68523106?lq=1) (Question score (upvotes - downvotes)) 22 (https://stackoverflow.com/questions/68523106/docker-bash-shell-script-does-not-catch-sigint-or-sigterm?noredirect=1&lq=1) Docker bash shell script does not catch SIGINT or SIGTERM (https://stackoverflow.com/q/64392543?lq=1) (Question score (upvotes - downvotes)) 10 (https://stackoverflow.com/questions/64392543/nginx-invalid-option-off-and-entrypoint-sh-permission-denied?noredirect=1&lq=1) nginx: invalid option: "off" and entrypoint.sh: : Permission denied (https://stackoverflow.com/q/66504462?lq=1) (Question score (upvotes - downvotes)) 1 (https://stackoverflow.com/questions/66504462/cant-execute-command-to-set-environment-variables-in-docker-container?noredirect=1&lq=1) Can't execute command to set environment variables in docker container (https://stackoverflow.com/questions/linked/47615751?lq=1) See more linked questions Related (https://stackoverflow.com/q/29982337?rq=3) (Question score (upvotes - downvotes)) 8 (https://stackoverflow.com/questions/29982337/docker-compose-and-execute-command-on-starting-container?rq=3) Docker Compose and execute command on starting container (https://stackoverflow.com/q/33572067?rq=3) (Question score (upvotes - downvotes)) 2 (https://stackoverflow.com/questions/33572067/can-i-run-a-bash-script-from-a-file-in-a-separate-docker-volume-before-a-contain?rq=3) Can I run a bash script from a file in a separate docker volume before a container starts? (https://stackoverflow.com/q/57101380?rq=3) (Question score (upvotes - downvotes)) 6 (https://stackoverflow.com/questions/57101380/docker-compose-run-commands-after-up?rq=3) docker-compose run commands after up (https://stackoverflow.com/q/58749540?rq=3) (Question score (upvotes - downvotes)) 1 (https://stackoverflow.com/questions/58749540/run-a-command-after-the-docker-container-has-started-running?rq=3) Run a command after the docker container has started running (https://stackoverflow.com/q/61711274?rq=3) (Question score (upvotes - downvotes)) 1 (https://stackoverflow.com/questions/61711274/run-bash-script-once-docker-container-is-loaded?rq=3) Run Bash script once Docker container is loaded (https://stackoverflow.com/q/66289766?rq=3) (Question score (upvotes - downvotes)) 7 (https://stackoverflow.com/questions/66289766/use-docker-compose-to-execute-a-script-right-before-the-container-is-stopped?rq=3) Use docker-compose to execute a script right before the container is stopped (https://stackoverflow.com/q/66844197?rq=3) (Question score (upvotes - downvotes)) 1 (https://stackoverflow.com/questions/66844197/run-a-script-after-docker-compose-run-npm?rq=3) run a script after docker-compose run (npm) (https://stackoverflow.com/q/67222223?rq=3) (Question score (upvotes - downvotes)) 0 (https://stackoverflow.com/questions/67222223/running-a-sh-script-when-container-starts-up-after-executing-docker-run?rq=3) Running a .sh script when container starts up after executing docker run (https://stackoverflow.com/q/71210462?rq=3) (Question score (upvotes - downvotes)) 1 (https://stackoverflow.com/questions/71210462/executing-a-startup-script-when-docker-container-is-up?rq=3) Executing a startup script when docker container is up (https://stackoverflow.com/q/71546815?rq=3) (Question score (upvotes - downvotes)) 2 (https://stackoverflow.com/questions/71546815/how-to-execute-script-by-host-after-starting-docker-container?rq=3) How to execute script by host after starting docker container (https://stackexchange.com/questions?tab=hot) Hot Network Questions (Gardening & Landscaping Stack Exchange) (https://gardening.stackexchange.com/questions/67739/are-these-trees-goners) Are these trees goners? (Astronomy Stack Exchange) (https://astronomy.stackexchange.com/questions/59536/how-could-we-have-determined-the-size-of-the-sun-without-the-moon) How could we have determined the size of the Sun without the moon? (Travel Stack Exchange) (https://travel.stackexchange.com/questions/193484/whats-required-to-travel-from-australia-london-europe) What's required to travel from Australia => London => Europe? (Physics Stack Exchange) (https://physics.stackexchange.com/questions/843644/does-a-larmor-precessing-spin-radiate-a-changing-magnetic-field) Does a Larmor precessing spin radiate a changing magnetic field? (Unix & Linux Stack Exchange) (https://unix.stackexchange.com/questions/791459/why-does-bash-give-the-following-result-after-brace-expansion) Why does bash give the following result after brace expansion? (Role-playing Games Stack Exchange) (https://rpg.stackexchange.com/questions/214807/how-are-rounding-principles-chosen-in-system-design) How are rounding principles chosen in system design? (Physics Stack Exchange) (https://physics.stackexchange.com/questions/843517/what-is-the-direction-of-dual-basis-vectors-relative-to-the-natural-basis-vector) What is the direction of dual basis vectors relative to the natural basis vectors? (MathOverflow) (https://mathoverflow.net/questions/488339/what-is-the-determinant-of-a-set) What is the determinant of a set? (TeX - LaTeX Stack Exchange) (https://tex.stackexchange.com/questions/737736/how-to-type-the-letter-for-letter-equivalence-sign) How to type the letter-for-letter equivalence sign? (Information Security Stack Exchange) (https://security.stackexchange.com/questions/280639/how-are-users-traced-via-their-ip-when-isps-use-nat) How are users traced via their IP when ISPs use NAT? (Home Improvement Stack Exchange) (https://diy.stackexchange.com/questions/315085/varying-voltage-detected-on-frame-of-stove) Varying voltage detected on frame of stove (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" (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? (Aviation Stack Exchange) (https://aviation.stackexchange.com/questions/108045/can-you-tell-an-autopilot-to-make-the-plane-go-a-specific-ground-speed) Can you tell an autopilot to make the plane go a specific ground speed? (Academia Stack Exchange) (https://academia.stackexchange.com/questions/216989/bsc-thesis-with-no-significant-results) BSc: Thesis with no significant results (Philosophy Stack Exchange) (https://philosophy.stackexchange.com/questions/122942/why-is-cogito-needed-as-a-step-in-dubito-ergo-cogito-ergo-sum) Why is "cogito" needed as a step in "dubito, ergo cogito, ergo sum"? (TeX - LaTeX Stack Exchange) (https://tex.stackexchange.com/questions/737678/how-to-get-over-line-with-round-corners) How to get over line with round corners? (Physics Stack Exchange) (https://physics.stackexchange.com/questions/843709/string-theory-in-curved-spacetime) String Theory in Curved Spacetime (Home Improvement Stack Exchange) (https://diy.stackexchange.com/questions/315025/leviton-bsrdp-w-in-the-united-states) Leviton BSRDP-W in the United States (Academia Stack Exchange) (https://academia.stackexchange.com/questions/216940/my-thesis-supervisor-published-a-paper-from-my-ma-thesis-with-herself-as-first-a) My thesis supervisor published a paper from my MA thesis with herself as first author without my consent (Puzzling Stack Exchange) (https://puzzling.stackexchange.com/questions/130619/what-is-the-angle-seven-circles-in-a-triangle) What is the angle? (seven circles in a triangle) (Home Improvement Stack Exchange) (https://diy.stackexchange.com/questions/315070/identify-this-contradictory-and-potentially-mislabeled-electrical-device) Identify this (contradictory and potentially mislabeled) electrical device (Retrocomputing Stack Exchange) (https://retrocomputing.stackexchange.com/questions/31312/c-recursion-and-the-hp-1000) C, recursion and the HP-1000 (Law Stack Exchange) (https://law.stackexchange.com/questions/107513/can-your-health-insurance-subrogation-clause-be-used-to-pursue-you-personally) Can Your Health Insurance Subrogation Clause Be Used to Pursue You Personally? (/feeds/question/47615751) (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/47615751) () 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.21.22958 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