elasticsearch - How can I run script automatically after Docker container startup - 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/47671589/how-can-i-run-script-automatically-after-docker-container-startup) (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 run script automatically after Docker container startup') (/feeds/question/47671589) (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%2f47671589%2fhow-can-i-run-script-automatically-after-docker-container-startup) Sign up or (https://stackoverflow.com/users/login?ssrc=site_switcher&returnurl=https%3a%2f%2fstackoverflow.com%2fquestions%2f47671589%2fhow-can-i-run-script-automatically-after-docker-container-startup) 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%2f47671589%2fhow-can-i-run-script-automatically-after-docker-container-startup) Log in (https://stackoverflow.com/users/signup?ssrc=head&returnurl=https%3a%2f%2fstackoverflow.com%2fquestions%2f47671589%2fhow-can-i-run-script-automatically-after-docker-container-startup) 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 google-sheets c++11 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 azure-devops awk 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 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 react-router nlp 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 jackson controller yii nested grep xamarin.ios static dockerfile statistics 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 css-selectors android-listview 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 dialog garbage-collection 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 c++17 delegates 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/47671589/how-can-i-run-script-automatically-after-docker-container-startup) How can I run script automatically after Docker container startup (/questions/ask) Ask Question (2017-12-06 10:05:44Z) Asked 7 years, 2 months ago Modified (?lastactivity) (2024-02-15 19:31:51Z) 1 year ago (Viewed 162,023 times) Viewed 162k times This question shows research effort; it is useful and clear (70:3:31e,16:d492858ea152e3a3,10:1740472894,16:ca302d838145cf61,8:47671589,91f8bcbff3f3c7027244943a7f777a278736f8679ec7bd96370f7d92d158eebe) 32 (This question does not show any research effort; it is unclear or not useful) (70:3:31e,16:0493b08d56319fb1,10:1740472894,16:0c35190c23841509,8:47671589,edc3f0d66bec4ef9ace43739191bed157c96d57c8400c8cecf3a9c49daf09396) Save this question. (/posts/47671589/timeline) Show activity on this post. I'm using Search Guard plugin to secure an elasticsearch cluster composed of multiple nodes. Here is my Dockerfile: #!/bin/sh FROM docker.elastic.co/elasticsearch/elasticsearch:5.6.3 USER root # Install search guard RUN bin/elasticsearch-plugin install --batch com.floragunn:search-guard-5:5.6.3-16 \ && chmod +x \ plugins/search-guard-5/tools/hash.sh \ plugins/search-guard-5/tools/sgadmin.sh \ bin/init_sg.sh \ && chown -R elasticsearch:elasticsearch /usr/share/elasticsearch USER elasticsearch To initialize SearchGuard (create internal users and assign roles). I need to run the script init_sg.sh after the container startup. Here is the problem: Unless elasticsearch is running, the script will not initialize any security index. The script's content is : sleep 10 plugins/search-guard-5/tools/sgadmin.sh -cd config/ -ts config/truststore.jks -ks config/kirk-keystore.jks -nhnv -icl Now, I just run the script manually after the container startup but since I'm running it on Kubernetes.. Pods may get killed or fail and get recreated automatically for some reason. In this case, the plugin have to be initialized automatically after the container startup! So how to accomplish this? Any help or hint would be really appreciated. (/questions/tagged/docker) (show questions tagged 'docker') docker (/questions/tagged/elasticsearch) (show questions tagged 'elasticsearch') elasticsearch (/questions/tagged/kubernetes) (show questions tagged 'kubernetes') kubernetes (/questions/tagged/dockerfile) (show questions tagged 'dockerfile') dockerfile (/questions/tagged/elasticsearch-plugin) (show questions tagged 'elasticsearch-plugin') elasticsearch-plugin (/q/47671589) (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/47671589/edit) () Improve this question Follow (70:3:31e,16:b4c75f1089f4946a,10:1740472894,16:c670d8fa4ad95314,8:47671589,b8d8b8f3ca49feaf066c8b318c1d59bb82d4b36e09eeeda4116201d5abbfdf8c) Follow this question to receive notifications asked (2017-12-06 10:05:44Z) Dec 6, 2017 at 10:05 (/users/3980759/philojunkie) (PhiloJunkie's user avatar) (/users/3980759/philojunkie) PhiloJunkie PhiloJunkie (reputation score) 1,169 (4 gold badges) 4 4 gold badges (13 silver badges) 13 13 silver badges (27 bronze badges) 27 27 bronze badges 3 (number of 'useful comment' votes received) 1 You will only need to initialize SG once per cluster. Re-initialize SG on every restart of a pod will overwrite any custom roles/permissions not saved. – (/users/1272760/nafooesi) (1,267 reputation) nafooesi Commented (2019-09-11 22:51:54Z, License: CC BY-SA 4.0) Sep 11, 2019 at 22:51 @nafooesi Absolutely, you are right! The SG should be initialized only once per cluster. – (/users/3980759/philojunkie) (1,169 reputation) PhiloJunkie Commented (2019-09-15 18:17:52Z, License: CC BY-SA 4.0) Sep 15, 2019 at 18:17 This question is also addressed (https://stackoverflow.com/questions/45371521/adding-startup-script-to-dockerfile/64935472#64935472) here – (/users/14336373/manishm) (137 reputation) ManishM Commented (2020-11-20 19:17:11Z, License: CC BY-SA 4.0) Nov 20, 2020 at 19:17 (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) 8 Answers 8 Sorted by: (/questions/47671589/how-can-i-run-script-automatically-after-docker-container-startup?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:0c85ae597ad4877a,10:1740472894,16:786ab10341e816a4,8:47671839,f160d6b209658a5bc1e97e53c6c7bd9cda8db9036a0a366873a1e274e7218a70) 30 (This answer is not useful) (70:3:31e,16:93b67729ae73bf8d,10:1740472894,16:acbdae75404bd4c6,8:47671839,8d2eb9960be68a9c8ea711e4d299f085a4501852c73651a6fe3202dcc6da8728) Save this answer. (Loading when this answer was accepted…) (/posts/47671839/timeline) Show activity on this post. The image itself has an entrypoint ENTRYPOINT ["/run/entrypoint.sh"] specified in the Dockerfile. You can replace it by your own script. So for example create a new script, mount it and first call /run/entrypoint.sh and then wait for start of elasticsearch before running your init_sg.sh . (/a/47671839) (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/47671839/edit) () Improve this answer Follow (70:3:31e,16:13337e8b4f1b20b9,10:1740472894,16:9906254098b9638f,8:47671839,faf6866a9cc2f5f2e6030e65c95ab1a0665203c0b39233ec78de63ec2481330c) Follow this answer to receive notifications (/posts/47671839/revisions) (show all edits to this post) edited (2018-09-04 17:34:02Z) Sep 4, 2018 at 17:34 (/users/3183756/caub) (caub's user avatar) (/users/3183756/caub) caub (reputation score) 2,769 (2 gold badges) 2 2 gold badges (30 silver badges) 30 30 silver badges (32 bronze badges) 32 32 bronze badges answered (2017-12-06 10:18:25Z) Dec 6, 2017 at 10:18 (/users/5979559/jonathan-lechner) (Jonathan Lechner's user avatar) (/users/5979559/jonathan-lechner) Jonathan Lechner Jonathan Lechner (reputation score) 581 (4 silver badges) 4 4 silver badges (9 bronze badges) 9 9 bronze badges 4 (number of 'useful comment' votes received) 3 I'm trying to do the exact same thing, but the /run/entrypoint.sh is not present in the container. I can't find where it sits. Any help? – (/users/2598292/redgiant) (4,748 reputation) RedGiant Commented (2018-05-25 12:37:48Z, License: CC BY-SA 4.0) May 25, 2018 at 12:37 (this comment was edited 1 time) Found it at /entrypoint.sh for elasticsearch:1.5.2 – (/users/4478667/marieke) (263 reputation) Marieke Commented (2021-06-24 16:50:54Z, License: CC BY-SA 4.0) Jun 24, 2021 at 16:50 Can you please specify how to mount it ? – (/users/913098/gulzar) (28,014 reputation) Gulzar Commented (2021-11-27 19:41:44Z, License: CC BY-SA 4.0) Nov 27, 2021 at 19:41 (number of 'useful comment' votes received) 1 You can use (https://docs.docker.com/engine/reference/builder/#add) ADD in Dockerfile command to add script to the container statically. If you change the script often and do not want to rebuild the image every time, you can make a script which is called from entrypoint.sh, and make all changes there. – (/users/3535036/do-do-new) (982 reputation) Do-do-new Commented (2023-03-12 09:51:23Z, License: CC BY-SA 4.0) Mar 12, 2023 at 9:51 (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:186842fe506883d8,10:1740472894,16:04453f2d2a4a65ff,8:47671892,ee488a225c23e6cb588fe3e1c89c96e3874e336ade288bb2d4d9bf32c9bbf47b) 8 (This answer is not useful) (70:3:31e,16:92187cf3b5a388a9,10:1740472894,16:4f7a52391a8615af,8:47671892,ed3f44353cacca4accd562fba51b79bdd183bac88377d9a71a688fcb1e3f8ecc) Save this answer. (Loading when this answer was accepted…) (/posts/47671892/timeline) Show activity on this post. Not sure this will solves your problem, but its worth check my (https://github.com/veerendra2/searx-with-dnscrypt) repo 'sDockerfile I have created a simple run.sh file copied to docker image and in the Dockerfile I wrote CMD ["run.sh"] . In the same way define whatever you want in run.sh and write CMD ["run.sh"] . You can find another example like below Dockerfile FROM java:8 RUN apt-get update && apt-get install stress-ng -y ADD target/restapp.jar /restapp.jar COPY dockerrun.sh /usr/local/bin/dockerrun.sh RUN chmod +x /usr/local/bin/dockerrun.sh CMD ["dockerrun.sh" ] dockerrun.sh #!/bin/sh java -Dserver.port=8095 -jar /restapp.jar & hostname="hostname: `hostname`" nohup stress-ng --vm 4 & while true ; do sleep 1000 done (/a/47671892) (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/47671892/edit) () Improve this answer Follow (70:3:31e,16:e68cbc366269f7eb,10:1740472894,16:f40483010d3c2b1a,8:47671892,c36fa42d493147689385cbed85c0768f9d2688bd736fb03d59f2e0b21df9804a) Follow this answer to receive notifications (/posts/47671892/revisions) (show all edits to this post) edited (2017-12-06 10:25:36Z) Dec 6, 2017 at 10:25 answered (2017-12-06 10:20:29Z) Dec 6, 2017 at 10:20 (/users/2200798/veerendra2) (veerendra2's user avatar) (/users/2200798/veerendra2) veerendra2 veerendra2 (reputation score) 2,273 (7 gold badges) 7 7 gold badges (37 silver badges) 37 37 silver badges (65 bronze badges) 65 65 bronze badges 1 (number of 'useful comment' votes received) 2 thanks for the reply, the elasticsearch image has already an entrypoint.sh file, using CMD like this will override it and elasticsearch search won't start at all :/ – (/users/3980759/philojunkie) (1,169 reputation) PhiloJunkie Commented (2017-12-06 15:09:00Z, License: CC BY-SA 3.0) Dec 6, 2017 at 15:09 (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:3f27c56512ce9fa1,10:1740472894,16:87074de1d7636792,8:64935619,893148590f4f6ba797ad61122c0f54744ccfaa538b871cd4b3daffa2bbaa64ce) 7 (This answer is not useful) (70:3:31e,16:fcf24750fe792b09,10:1740472894,16:45bd96dd4de09af8,8:64935619,120b349b144a7293efd44c48393703c58d67c55764442b1ba04ad15c49cf18e2) Save this answer. (Loading when this answer was accepted…) (/posts/64935619/timeline) Show activity on this post. This is addressed in the documentation here: (https://docs.docker.com/config/containers/multi-service_container/) https://docs.docker.com/config/containers/multi-service_container/ If one of your processes depends on the main process, then start your helper process FIRST with a script like wait-for-it, then start the main process SECOND and remove the fg %1 line. #!/bin/bash # turn on bash's job control set -m # Start the primary process and put it in the background ./my_main_process & # Start the helper process ./my_helper_process # the my_helper_process might need to know how to wait on the # primary process to start before it does its work and returns # now we bring the primary process back into the foreground # and leave it there fg %1 (/a/64935619) (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/64935619/edit) () Improve this answer Follow (70:3:31e,16:26197b3621fbb255,10:1740472894,16:246ef1ecd7527d4c,8:64935619,7cd6b6dbd42f80ece3a742fab1ccc150c12c7bf1b7e02abef2fb5ad66ef8e93f) Follow this answer to receive notifications answered (2020-11-20 19:19:14Z) Nov 20, 2020 at 19:19 (/users/14336373/manishm) (ManishM's user avatar) (/users/14336373/manishm) ManishM ManishM (reputation score) 137 (2 silver badges) 2 2 silver badges (3 bronze badges) 3 3 bronze badges 1 duplicated here (https://stackoverflow.com/questions/45371521/adding-startup-script-to-dockerfile/64935472#64935472) (adding startup script to dockerfile) stackoverflow.com/questions/45371521/… – (/users/14336373/manishm) (137 reputation) ManishM Commented (2020-11-20 19:19:49Z, License: CC BY-SA 4.0) Nov 20, 2020 at 19:19 (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:4b49b87b7df2f5d4,10:1740472894,16:e9bdf0674d7a2487,8:55719193,64d3105e8d557552ce896cd81f5fb8f23f479347f1a0a3e3b1cce071db1267d7) 5 (This answer is not useful) (70:3:31e,16:45c13271ee6e3d97,10:1740472894,16:16df0e9f81024e11,8:55719193,2bd737db99db91d21598055732967c6e43033f120bde10f7decbd5884faaa993) Save this answer. (Loading when this answer was accepted…) (/posts/55719193/timeline) Show activity on this post. I was trying to solve the exact problem. Here's the approach that worked for me. Create a separate shell script that checks for ES status, and only start initialization of SG when ES is ready: Shell Script #!/bin/sh echo ">>>> Right before SG initialization <<<<" # use while loop to check if elasticsearch is running while true do netstat -uplnt | grep :9300 | grep LISTEN > /dev/null verifier=$? if [ 0 = $verifier ] then echo "Running search guard plugin initialization" /elasticsearch/plugins/search-guard-6/tools/sgadmin.sh -h 0.0 .0 .0 -cd plugins/search-guard-6/sgconfig -icl -key config/client.key -cert config/client.pem -cacert config/root-ca.pem -nhnv break else echo "ES is not running yet" sleep 5 fi done Install script in Dockerfile You will need to install the script in container so it's accessible after it starts. COPY sginit.sh / RUN chmod +x /sginit.sh Update entrypoint script You will need to edit the entrypoint script or run script of your ES image. So that it starts the sginit.sh in the background BEFORE starting ES process. # Run sginit in background waiting for ES to start /sginit.sh & This way the sginit.sh will start in the background, and will only initialize SG after ES is started. The reason to have this sginit.sh script starts before ES in the background is so that it's not blocking ES from starting. The same logic applies if you put it after starting of ES, it will never run unless you put the starting of ES in the background. (/a/55719193) (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/55719193/edit) () Improve this answer Follow (70:3:31e,16:f0dee2d2e7cabe40,10:1740472894,16:e92397f245300181,8:55719193,a7c919bd1663673633debb9a02bb596357a41a20328f843b454e1b934fa07d31) Follow this answer to receive notifications (/posts/55719193/revisions) (show all edits to this post) edited (2020-06-20 09:12:55Z) Jun 20, 2020 at 9:12 (/users/-1/community) (Community's user avatar) (/users/-1/community) Community (Community Bot — not a real person. Replies to this bot are not monitored.) Bot (reputation score) 1 (1 silver badge) 1 1 silver badge answered (2019-04-17 02:50:43Z) Apr 17, 2019 at 2:50 (/users/1272760/nafooesi) (nafooesi's user avatar) (/users/1272760/nafooesi) nafooesi nafooesi (reputation score) 1,267 (13 silver badges) 13 13 silver badges (18 bronze badges) 18 18 bronze badges 3 How to wait for the ES get started, then initialize the SG? – (/users/7794308/akira) (273 reputation) Akira Commented (2019-09-10 21:20:09Z, License: CC BY-SA 4.0) Sep 10, 2019 at 21:20 (number of 'useful comment' votes received) 1 As commented below the original question, you do NOT want to initialize SG every single time. It will overwrite any modified config when a pod restarts. SG should only be initialized once per cluster at the beginning. If you need to run some other script after ES starts, my script can be used as an example to detect if ES is running in the background before kicking off the script. – (/users/1272760/nafooesi) (1,267 reputation) nafooesi Commented (2019-12-03 01:23:34Z, License: CC BY-SA 4.0) Dec 3, 2019 at 1:23 The general approach described here is very useful. I had a similar problem (not with ES), where I wanted to run a script after the main process had a chance to start up. This pattern worked like a charm! – (/users/2686286/bischoje) (197 reputation) bischoje Commented (2020-02-25 20:07:15Z, License: CC BY-SA 4.0) Feb 25, 2020 at 20:07 (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:697aaf8d0593e7d1,10:1740472894,16:87158d6405c6b08e,8:64407602,446d96c14a6443f0977551ad43b0034b4d3a17fcaaceda01fed48c473cdd70b8) 3 (This answer is not useful) (70:3:31e,16:668014197a4260b9,10:1740472894,16:c4a7a30c06481105,8:64407602,1d74097b5f3e07ca7ddff5520eb45c84d25f6aacacb5c7c1e3c7d9b8eb92eb6f) Save this answer. (Loading when this answer was accepted…) (/posts/64407602/timeline) Show activity on this post. You can also use (https://github.com/vishnubob/wait-for-it) wait-for-it script. It will wait on the availability of a host and TCP port. It is useful for synchronizing the spin-up of interdependent services and works like a charm with containers. It does not have any external dependencies so you can just run it as an RUN command without doing anything else. A Dockerfile example based on this (https://stackoverflow.com/questions/35526532/how-to-add-an-elasticsearch-index-during-docker-build) thread : FROM elasticsearch # Make elasticsearch write data to a folder that is not declared as a volume in elasticsearchs' official dockerfile. RUN mkdir /data && chown -R elasticsearch:elasticsearch /data && echo 'es.path.data: /data' >> config/elasticsearch.yml && echo 'path.data: /data' >> config/elasticsearch.yml # Download wait-for-it ADD https://raw.githubusercontent.com/vishnubob/wait-for-it/e1f115e4ca285c3c24e847c4dd4be955e0ed51c2/wait-for-it.sh /utils/wait-for-it.sh # Copy the files you may need and your insert script # Insert data into elasticsearch RUN /docker-entrypoint.sh elasticsearch -p /tmp/epid & /bin/bash /utils/wait-for-it.sh -t 0 localhost:9200 -- path/to/insert/script.sh; kill $(cat /tmp/epid) && wait $(cat /tmp/epid); exit 0 ; (/a/64407602) (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/64407602/edit) () Improve this answer Follow (70:3:31e,16:b7dbd4908bb17d61,10:1740472894,16:fa7ab610d4a7ec1f,8:64407602,6cdf01a576b5b69fd569a4be7a2cb27fe96466b5942952ea4d5d13953d9350ed) Follow this answer to receive notifications answered (2020-10-17 21:37:18Z) Oct 17, 2020 at 21:37 (/users/14469823/encodedwitch) (encodedwitch's user avatar) (/users/14469823/encodedwitch) encodedwitch encodedwitch (reputation score) 31 (1 bronze badge) 1 1 bronze badge 1 wait-for-it from master branch: (https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh) raw.githubusercontent.com/vishnubob/wait-for-it/master/… – (/users/1764521/damien-golding) (1,000 reputation) Damien Golding Commented (2023-07-25 11:03:33Z, License: CC BY-SA 4.0) Jul 25, 2023 at 11:03 (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:2c6a25208b92a915,10:1740472894,16:fcf9603427b69d82,8:47672205,6625bcdaa3eceb078f491905f797e8e4faf0032eafb72fe318a94e2294d3e61d) 2 (This answer is not useful) (70:3:31e,16:3aa5ee72f2fc8504,10:1740472894,16:cbb027637ba57042,8:47672205,ee13d7e0b4a25a635f74e2fb6c60838d2bced2bc4a20075938c30efb9877d93f) Save this answer. (Loading when this answer was accepted…) (/posts/47672205/timeline) Show activity on this post. I would suggest to put the CMD in you docker file to execute the script when the container start FROM debian RUN apt-get update && apt-get install -y nano && apt-get clean EXPOSE 8484 CMD ["/bin/bash" , "/opt/your_app/init.sh" ] There is other way , but before using this look at your requirement, ENTRYPOINT "put your code here" && /bin/bash #exemple ENTRYPOINT service nginx start && service ssh start &&/bin/bash "use && to separate your code" (/a/47672205) (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/47672205/edit) () Improve this answer Follow (70:3:31e,16:f7de6f87b5549dfa,10:1740472894,16:5f21cb7573a5c542,8:47672205,e18c348319153d9aec41db7f8fadeeda2c1357859914fa8358e6f14db20e7402) Follow this answer to receive notifications answered (2017-12-06 10:37:51Z) Dec 6, 2017 at 10:37 (/users/1109179/sohan) (Sohan's user avatar) (/users/1109179/sohan) Sohan Sohan (reputation score) 6,809 (6 gold badges) 6 6 gold badges (40 silver badges) 40 40 silver badges (58 bronze badges) 58 58 bronze badges 2 this solution overrides the entrypoint which is provided by Elasticsearch Image – (/users/3980759/philojunkie) (1,169 reputation) PhiloJunkie Commented (2017-12-06 15:06:11Z, License: CC BY-SA 3.0) Dec 6, 2017 at 15:06 I have no looked into elasticseacrh image installation as such, do you mean this does not work for you? – (/users/1109179/sohan) (6,809 reputation) Sohan Commented (2017-12-07 06:05:10Z, License: CC BY-SA 3.0) Dec 7, 2017 at 6:05 (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:f362f44c2a68758e,10:1740472894,16:9ca0267b4a05ea86,8:75950598,53cc42b41c4793d8d5eb04f52948a5e8fb9d117b9789225d769b92bd5090ff03) 1 (This answer is not useful) (70:3:31e,16:d1718d790da92f1e,10:1740472894,16:ec5829f935637071,8:75950598,3f93f177df5507160c3048f9a8be454ddd2fc85869bfa074ea326ca88d02d64d) Save this answer. (Loading when this answer was accepted…) (/posts/75950598/timeline) Show activity on this post. There is a dedicated tool for this - (https://github.com/just-containers/s6-overlay) s6-overlay .To quote from their description: A simple init process which allows the end-user to execute tasks like initialization (...) Multiple processes in a single container (...) Able to operate in "The Docker Way" The repo provides lengthy explanation how it works, how to install etc. which I won't repeat here. Example Imo their repo lacks a working, straightforward minimal example how to run a process + a script so I provide one. I modify the example they provide in their docs.Say we want to run nginx (or any process that runs until end of container lifetime) plus some shell script myscript.sh . Local directory structure: ./Dockerfile ./myscript.sh ./s6-overlay/s6-rc.d/myapp/type ./s6-overlay/s6-rc.d/myapp/up ./s6-overlay/s6-rc.d/user/contents.d/myapp Dockerfile : FROM ubuntu ARG S6_OVERLAY_VERSION=3.1.4.1 RUN apt-get update && apt-get install -y nginx xz-utils RUN echo "daemon off;" >> /etc/nginx/nginx.conf # Minimal set of dependecies required for s6 ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-noarch.tar.xz /tmp RUN tar -C / -Jxpf /tmp/s6-overlay-noarch.tar.xz ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-x86_64.tar.xz /tmp RUN tar -C / -Jxpf /tmp/s6-overlay-x86_64.tar.xz # Overhead of files to manage processes via s6 COPY s6-overlay /etc/s6-overlay # Copy the script we intend to run COPY myscript.sh /home # CMD is the main process - nothing special here CMD ["/usr/sbin/nginx" ] # ENTRYPOINT must be /init for s6 to work ENTRYPOINT ["/init" ] myscript.sh - make sure to make it executable: #!/bin/bash echo "foo" > /home/foo.txt echo "bar" > /home/bar.txt s6-overlay/s6-rc.d/myapp/type : oneshot "an up file contains a single command line" so as soon our script has >1 line, we have to outsource our script to a separate file. Therefore this is our s6-overlay/s6-rc.d/myapp/up : /home/myscript.sh s6-overlay/s6-rc.d/myapp/contents.d/myapp is an empty file. Now we simply need to docker build (...) and docker run -p 80:80 (...) . If you have done everything correctly, you should see a log message s6-rc: info: service myapp successfully started at container startup.You can then visit localhost:80 and run docker exec CONTAINER bash -c "cat /home/foo.txt" to confirm it works as expected. Note that utilizing s6-rc.d is the recommended way to do it. There's also a legacy way to accomplish this with less overhead by putting myscript.sh into folder /etc/cont-init.d/ . (/a/75950598) (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/75950598/edit) () Improve this answer Follow (70:3:31e,16:cdffed00a8cbccb2,10:1740472894,16:75c4be84b284ae2a,8:75950598,feabc0e91189f353063656819c29a97110c4d33e162643621d8be3f645dcdc58) Follow this answer to receive notifications (/posts/75950598/revisions) (show all edits to this post) edited (2023-04-06 14:40:17Z) Apr 6, 2023 at 14:40 answered (2023-04-06 14:18:28Z) Apr 6, 2023 at 14:18 (/users/6312338/nichoio) (nichoio's user avatar) (/users/6312338/nichoio) nichoio nichoio (reputation score) 7,667 (4 gold badges) 4 4 gold badges (31 silver badges) 31 31 silver badges (42 bronze badges) 42 42 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) This answer is useful (70:3:31e,16:8e49c5f4b172c0f9,10:1740472894,16:e1e3deb2d0705223,8:78003499,0fca88e186633a31030ffbbe3261db7b5b54818d837137f43f84a7a0ed60a41f) 0 (This answer is not useful) (70:3:31e,16:51d0c7a259e9178f,10:1740472894,16:24c74cf5f422fcf9,8:78003499,f1dcc6bdc6a4085b80eee74654fc3df26bb0727f6784fbf56c14bccee3113bcc) Save this answer. (Loading when this answer was accepted…) (/posts/78003499/timeline) Show activity on this post. My success would be adding my script to CMD or ENTRYPOINT Then add the bootom of the script i made run include the start application at the bottom. apachectl -D FOREGROUND (/a/78003499) (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/78003499/edit) () Improve this answer Follow (70:3:31e,16:e5b8630d9e6de981,10:1740472894,16:225fd34ddc4f6cb7,8:78003499,e842f61a3e1189550b7b732ef96481931551ec8af5ad3737e8a1a47dfa5ed48e) Follow this answer to receive notifications answered (2024-02-15 19:31:51Z) Feb 15, 2024 at 19:31 (/users/4478532/cyford-technologies-llc) (Cyford Technologies LLC's user avatar) (/users/4478532/cyford-technologies-llc) Cyford Technologies LLC Cyford Technologies LLC (reputation score) 31 (7 bronze badges) 7 7 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) (47671589) (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%2f47671589%2fhow-can-i-run-script-automatically-after-docker-container-startup%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/elasticsearch) (show questions tagged 'elasticsearch') elasticsearch (/questions/tagged/kubernetes) (show questions tagged 'kubernetes') kubernetes (/questions/tagged/dockerfile) (show questions tagged 'dockerfile') dockerfile (/questions/tagged/elasticsearch-plugin) (show questions tagged 'elasticsearch-plugin') elasticsearch-plugin or (/questions/ask) ask your own question . The Overflow Blog (https://stackoverflow.blog/2025/02/21/one-quality-every-engineering-manager-should-have-empathy/?cb=1) One quality every engineering manager should have? Empathy. (https://stackoverflow.blog/2025/02/24/writing-tests-with-ai-but-not-llms/?cb=1) Writing tests with AI, but not LLMs 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/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... (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 Linked (https://stackoverflow.com/q/35526532?lq=1) (Question score (upvotes - downvotes)) 40 (https://stackoverflow.com/questions/35526532/how-to-add-an-elasticsearch-index-during-docker-build?noredirect=1&lq=1) How to add an elasticsearch index during docker build (https://stackoverflow.com/q/45371521?lq=1) (Question score (upvotes - downvotes)) 18 (https://stackoverflow.com/questions/45371521/adding-startup-script-to-dockerfile?noredirect=1&lq=1) adding startup script to dockerfile (https://stackoverflow.com/q/50529574?lq=1) (Question score (upvotes - downvotes)) 2 (https://stackoverflow.com/questions/50529574/how-can-i-run-a-searchguard-set-up-script-after-elasticsearch-is-up-and-running?noredirect=1&lq=1) How can I run a searchguard set up script after elasticsearch is up and running in docker? (https://stackoverflow.com/q/70987785?lq=1) (Question score (upvotes - downvotes)) 0 (https://stackoverflow.com/questions/70987785/how-to-persist-created-database-on-dockerhub?noredirect=1&lq=1) How to persist created database on dockerhub Related (https://stackoverflow.com/q/33799195?rq=3) (Question score (upvotes - downvotes)) 7 (https://stackoverflow.com/questions/33799195/how-to-run-a-script-at-the-start-of-container-in-cloud-containers-engine-with-ku?rq=3) How to Run a script at the start of Container in Cloud Containers Engine with Kubernetes (https://stackoverflow.com/q/37638298?rq=3) (Question score (upvotes - downvotes)) 2 (https://stackoverflow.com/questions/37638298/enable-scripting-within-docker-image?rq=3) enable scripting within docker image (https://stackoverflow.com/q/38374567?rq=3) (Question score (upvotes - downvotes)) 1 (https://stackoverflow.com/questions/38374567/dockerfile-with-entrypoint-for-executing-bash-script?rq=3) Dockerfile with entrypoint for executing bash script (https://stackoverflow.com/q/49746102?rq=3) (Question score (upvotes - downvotes)) 2 (https://stackoverflow.com/questions/49746102/execute-script-when-docker-container-start?rq=3) Execute script when docker container start (https://stackoverflow.com/q/57328079?rq=3) (Question score (upvotes - downvotes)) 6 (https://stackoverflow.com/questions/57328079/how-to-run-sh-file-when-container-is-running-using-dockerfile?rq=3) how to run .sh file when container is running using dockerfile (https://stackoverflow.com/q/57820612?rq=3) (Question score (upvotes - downvotes)) 0 (https://stackoverflow.com/questions/57820612/running-a-bash-script-after-some-containers-are-initialized?rq=3) Running a bash script after some containers are initialized (https://stackoverflow.com/q/59871513?rq=3) (Question score (upvotes - downvotes)) 2 (https://stackoverflow.com/questions/59871513/how-can-i-make-the-docker-container-to-run-a-script-every-time-when-the-containe?rq=3) How can I make the docker container to run a script every time when the container restart? (https://stackoverflow.com/q/60093050?rq=3) (Question score (upvotes - downvotes)) 1 (https://stackoverflow.com/questions/60093050/running-python-script-after-container-is-up-kubernetes?rq=3) Running python script after container is up (Kubernetes) (https://stackoverflow.com/q/65075374?rq=3) (Question score (upvotes - downvotes)) 0 (https://stackoverflow.com/questions/65075374/automate-calling-bash-commands-on-a-kubernetes-container?rq=3) Automate calling bash commands on a Kubernetes container (https://stackoverflow.com/q/68494230?rq=3) (Question score (upvotes - downvotes)) 1 (https://stackoverflow.com/questions/68494230/kubernetes-execute-script-before-container-start?rq=3) Kubernetes Execute Script Before Container Start (https://stackexchange.com/questions?tab=hot) Hot Network Questions (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"? (MathOverflow) (https://mathoverflow.net/questions/488383/are-there-finitely-many-smooth-projective-varieties-with-given-hodge-numbers-ove) Are there finitely many smooth projective varieties with given Hodge numbers over a given finite field? (Proof Assistants Stack Exchange) (https://proofassistants.stackexchange.com/questions/4767/redundant-assumptions-in-mltt-rules) Redundant assumptions in MLTT rules? (Law Stack Exchange) (https://law.stackexchange.com/questions/107512/can-i-be-charged-for-calling-the-police-in-germany-and-then-realising-it-s-not-a) Can I be charged for calling the police in Germany and then realising it’s not an emergency afterwards? (Biblical Hermeneutics Stack Exchange) (https://hermeneutics.stackexchange.com/questions/101754/why-was-the-temple-veil-torn-from-top-to-bottom) Why was the Temple veil torn from top to bottom? (TeX - LaTeX Stack Exchange) (https://tex.stackexchange.com/questions/737804/beamer-gotham-title-slide-right-margin) Beamer Gotham --- Title Slide Right Margin (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 (Mathematica Stack Exchange) (https://mathematica.stackexchange.com/questions/311168/tabular-shifts-dates-by-one-day) Tabular shifts dates by one day (Puzzling Stack Exchange) (https://puzzling.stackexchange.com/questions/130692/a-geometrical-puzzle-about-a-grazing-goat) A geometrical puzzle about a grazing goat (Cross Validated) (https://stats.stackexchange.com/questions/661794/clustered-standard-error-intuitions) Clustered standard error intuitions (Home Improvement Stack Exchange) (https://diy.stackexchange.com/questions/315114/streaks-after-painting-window-frames-with-primer-and-paint) Streaks after painting window frames with primer and paint (Astronomy Stack Exchange) (https://astronomy.stackexchange.com/questions/59545/why-are-asteroid-collisions-a-probability) Why are asteroid collisions a probability? (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? (Retrocomputing Stack Exchange) (https://retrocomputing.stackexchange.com/questions/31315/what-was-the-most-complete-encoding-for-english-before-unicode) What was the most complete encoding for English before Unicode? (Seasoned Advice) (https://cooking.stackexchange.com/questions/130249/why-cant-you-add-instant-yeast-to-liquid) Why can't you add instant yeast to liquid? (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? (Chinese Language Stack Exchange) (https://chinese.stackexchange.com/questions/59862/help-in-understanding-li-bais-%e5%a4%9c%e4%b8%8b%e5%be%81%e8%99%8f%e4%ba%ad) Help in understanding Li Bai's 《夜下征虏亭》 (Home Improvement Stack Exchange) (https://diy.stackexchange.com/questions/315098/adding-dedicated-gfci-circuit-no-room-for-neutral-ground-on-bars) Adding dedicated GFCI circuit, no room for neutral/ ground on bars (Space Exploration Stack Exchange) (https://space.stackexchange.com/questions/67945/could-india-possibly-deflect-the-asteroid-2024-yr4) Could India possibly deflect the asteroid 2024 YR4? (Mathematica Stack Exchange) (https://mathematica.stackexchange.com/questions/311180/strong-dynamic-chromostereopsis-illusion) Strong dynamic chromostereopsis illusion (Bicycles Stack Exchange) (https://bicycles.stackexchange.com/questions/96263/can-i-save-these-wheels) Can I save these wheels? (English Language & Usage Stack Exchange) (https://english.stackexchange.com/questions/629551/ownership-of-vs-ownership-by) "Ownership of" vs "ownership by" (Unix & Linux Stack Exchange) (https://unix.stackexchange.com/questions/791565/add-columns-from-variable-number-of-files-to-base-file) Add columns from variable number of files to base file (Unix & Linux Stack Exchange) (https://unix.stackexchange.com/questions/791566/cant-find-executable-file-that-is-obviously-present) Can't find executable file that is obviously present (/feeds/question/47671589) (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/47671589) () 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.23038 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