<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: ISSUE: Starting a Spunk Docker container via Dockerfile and adding it as a search peer in a bash script in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-start-a-Spunk-Docker-container-via-Dockerfile-and-adding/m-p/635739#M220876</link>
    <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/227250"&gt;@Tom_Lundie&lt;/a&gt;! It seems that I was running into scenario A (d&lt;EM&gt;ocker exec&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;is running before Splunk is up and ready&lt;/SPAN&gt;). I added a while loop to check my container logs and confirm that the playbook has completed running. This seems to have fixed the issue.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 23 Mar 2023 15:11:06 GMT</pubDate>
    <dc:creator>krishanp</dc:creator>
    <dc:date>2023-03-23T15:11:06Z</dc:date>
    <item>
      <title>How to start a Spunk Docker container via Dockerfile and adding it as a search peer in one bash script?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-start-a-Spunk-Docker-container-via-Dockerfile-and-adding/m-p/635384#M220743</link>
      <description>&lt;P class=""&gt;&lt;SPAN class=""&gt;Hello,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=""&gt;&lt;SPAN class=""&gt;I am attempting to start a Splunk docker container (search head) &lt;U&gt;and&lt;/U&gt; add it as a search peer to an existing environment all in one bash script but running in an issue. I am able to run each of the two steps separately without a problem but am running into an issue when I attempt to combine them into one script.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=""&gt;&lt;SPAN class=""&gt;I am able to build my Dockerfile and start the container successfully. I am running the below command to start a container with the name &lt;STRONG&gt;splunk_sh&lt;/STRONG&gt;.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;docker run -d --rm -it -p 8000:8000 --name splunk_sh dockersplunk:latest&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=""&gt;&lt;SPAN class=""&gt;After the container is up, I am also able to successfully add it as a search peer using the following command and script. (A copy of the &lt;STRONG&gt;search_peer.sh&lt;/STRONG&gt; script is being copied to my container via Dockerfile.)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;# search peer command
docker exec -it splunk_sh sh /opt/splunk/bin/search_peer.sh&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;search_peer.sh&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;#!/bin/bash
sudo /opt/splunk/bin/splunk add search-server https://&amp;lt;indexer_ip&amp;gt;:8089 -auth &amp;lt;user&amp;gt;:&amp;lt;password&amp;gt; -remoteUsername &amp;lt;user&amp;gt; -remotePassword &amp;lt;password&amp;gt;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Running the two above steps separately allows me to start my Splunk container and have it become a search peer. I begin to run into an issue when I try to run a script (&lt;STRONG&gt;docker_search_peer.sh&lt;/STRONG&gt;) that includes both steps, starting the&amp;nbsp;&lt;STRONG&gt;splunk_sh&lt;/STRONG&gt; container and the &lt;STRONG&gt;search peer command&lt;/STRONG&gt;.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;docker_search_peer.sh&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;#!/bin/bash
docker run -d --rm -it -p 8000:8000 --name splunk_sh dockersplunk:latest
docker exec -it splunk_sh sh /opt/splunk/bin/search_peer.sh&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I run my&amp;nbsp;&lt;STRONG&gt;docker_search_peer.sh&lt;/STRONG&gt; script, the container is able to start but is not able to become a search peer. I get the below error:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;ERROR: Couldn't determine $SPLUNK_HOME or $SPLUNK_ETC; perhaps one should be set in environment&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've disabled selinux (this was mentioned in a few different posts) but am still running into this issue. I'm not sure how I'm able to run commands/execute scripts separately but not together in one script. Any help or guidance would be much appreciated.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Mar 2023 20:19:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-start-a-Spunk-Docker-container-via-Dockerfile-and-adding/m-p/635384#M220743</guid>
      <dc:creator>krishanp</dc:creator>
      <dc:date>2023-03-22T20:19:11Z</dc:date>
    </item>
    <item>
      <title>Re: ISSUE: Starting a Spunk Docker container via Dockerfile and adding it as a search peer in a bash script</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-start-a-Spunk-Docker-container-via-Dockerfile-and-adding/m-p/635406#M220755</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/191601"&gt;@krishanp&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;I can't find that dockersplunk container image (I'm presuming it's a private one) but I'm thinking that one of two things might be going on here.&lt;/P&gt;&lt;P&gt;Either:&lt;/P&gt;&lt;P&gt;A) (most-likely) &lt;EM&gt;docker exec&lt;/EM&gt;&amp;nbsp;is running before Splunk is up and ready.&amp;nbsp;&lt;SPAN&gt;The command started using&amp;nbsp;&lt;/SPAN&gt;docker exec&lt;SPAN&gt;&amp;nbsp;only runs while the container’s primary process (&lt;/SPAN&gt;PID 1&lt;SPAN&gt;) is running.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;B) (less-likely based off your post) &lt;EM&gt;search_peer.sh&lt;/EM&gt;&amp;nbsp;is not running as the user that Splunk is running under.&lt;/P&gt;&lt;P&gt;Either way, make sure that neither of those are happening. Depending on how the dockerfile is structured, it's possible that Splunk is still being configured / starting whilst the &lt;EM&gt;search_peer.sh&lt;/EM&gt; is starting.&lt;/P&gt;&lt;P&gt;If you can, then I would either update the dockerfile to run the &lt;EM&gt;search_peer.sh&lt;/EM&gt; after Splunk is up. If that is not an option here, then you could modify either &lt;EM&gt;search_peer.sh&lt;/EM&gt; or&amp;nbsp;&lt;EM&gt;docker_search_peer.sh&lt;/EM&gt;&amp;nbsp;to wait until Splunk is up before adding the search peer. There are loads of examples out there around this (e.g. you could wait until SplunkWeb is listening on 8000).&lt;/P&gt;&lt;P&gt;Let me know how you get on. Good luck!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Mar 2023 22:13:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-start-a-Spunk-Docker-container-via-Dockerfile-and-adding/m-p/635406#M220755</guid>
      <dc:creator>Tom_Lundie</dc:creator>
      <dc:date>2023-03-21T22:13:02Z</dc:date>
    </item>
    <item>
      <title>Re: ISSUE: Starting a Spunk Docker container via Dockerfile and adding it as a search peer in a bash script</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-start-a-Spunk-Docker-container-via-Dockerfile-and-adding/m-p/635739#M220876</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/227250"&gt;@Tom_Lundie&lt;/a&gt;! It seems that I was running into scenario A (d&lt;EM&gt;ocker exec&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;is running before Splunk is up and ready&lt;/SPAN&gt;). I added a while loop to check my container logs and confirm that the playbook has completed running. This seems to have fixed the issue.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Mar 2023 15:11:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-start-a-Spunk-Docker-container-via-Dockerfile-and-adding/m-p/635739#M220876</guid>
      <dc:creator>krishanp</dc:creator>
      <dc:date>2023-03-23T15:11:06Z</dc:date>
    </item>
  </channel>
</rss>

