Libiticum.nl

Commandline, docker, linux, provisioning, tooling

jenkins with ansible,terraform,libvirt-clients and docker in docker

sander

Create this Dockerfile:


FROM jenkins/jenkins
USER root
RUN apt-get -y update && \
 apt-get -y install libvirt-clients curl software-properties-common lsb-release ansible apt-transport-https ca-certificates gnupg-agent  &&  curl -fsSL https://apt.releases.hashicorp.com/gpg | apt-key add - && \
 add-apt-repository  "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main" && \
 curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg && \
 echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian \
 $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null && \
 apt-get update && \
 apt-get -y install docker-ce docker-ce-cli containerd.io terraform && \
 curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
USER jenkins

Build the docker file with the command

docker build -t jenkins/libvirt_terraform_docker:1.0

Then start you container with the command:

docker run --name jenkins -d -v /volume1/docker/jenkins/data/:/var/jenkins_home -v /var/run/docker.sock:/var/run/docker.sock -p 8080:8080 -p 50000:50000 jenkins/libvirt_terraform_docker:1.0

Thanks for : https://itnext.io/docker-inside-docker-for-jenkins-d906b7b5f527

Back to top