Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@Meowzz95
Created June 14, 2019 09:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Meowzz95/69502126352e63de8c2f1826f113770f to your computer and use it in GitHub Desktop.
Save Meowzz95/69502126352e63de8c2f1826f113770f to your computer and use it in GitHub Desktop.
Docker file extending official Jenkins image, add docker support(share host docker)
FROM jenkins/jenkins:lts
# if we want to install via apt
USER root
ENV DOCKERVERSION=18.03.1-ce
RUN curl -fsSLO https://download.docker.com/linux/static/stable/x86_64/docker-${DOCKERVERSION}.tgz \
&& tar xzvf docker-${DOCKERVERSION}.tgz --strip 1 \
-C /usr/local/bin docker/docker \
&& rm docker-${DOCKERVERSION}.tgz
RUN groupadd docker
RUN usermod -aG docker jenkins
RUN chmod -v a+s $(which docker)
# drop back to the regular jenkins user - good practice
USER jenkins
@Meowzz95
Copy link
Author

And use this to run

docker run -d \
-v jenkins_home:/var/jenkins_home \
-v /var/run/docker.sock:/var/run/docker.sock \
-p 8089:8080 -p 50000:50000 \
-e JENKINS_OPTS="--prefix=/devops" \
--name my-jenkins \
my-jenkins

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