Skip to content

Instantly share code, notes, and snippets.

@jorritfolmer
Created January 8, 2016 16:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jorritfolmer/b216f2bdd1c9326f4aa5 to your computer and use it in GitHub Desktop.
Save jorritfolmer/b216f2bdd1c9326f4aa5 to your computer and use it in GitHub Desktop.

Dockerfile

# Well ok CENTOS then
FROM centos:7

# Point to your local repository with Splunk(forwarder)s
RUN echo $'[splunk]\n\
name=Splunk\n\
baseurl=http://repo.testlab.local/splunk\n\
enabled=1\n\
gpgcheck=0\n'\
> /etc/yum.repos.d/splunk.repo

# Create init script, first line one to accept license, 2nd to run splunk in the foreground
RUN echo $'#!/bin/bash\n\
/opt/splunk/bin/splunk status --accept-license --answer-yes --no-prompt\n\
/opt/splunk/bin/splunk start --nodaemon'\
> /sbin/myinit.sh && chmod 755 /sbin/myinit.sh

# Install Splunk
RUN yum -y install splunk

# Expose all teh ports
EXPOSE 8000/tcp 8089/tcp 8191/tcp 9997/tcp

WORKDIR /opt/splunk

# Start splunk
CMD ["/sbin/myinit.sh"]

Build

docker build --rm -t local/splunk .

Run

docker run -ti -p 8000:8000 -p 8089:8089 -p 8191:8191 local/splunk

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment