<p>I have several flask applications within a Kubernetes cluster. Now the idea is to test such images before they touch production. And I ended up into Jenkins.</p>
<p>I deployed a docker image of Jenkins, set it up and was able to attach to my repositories. The first issue that occurred is the dependencies. As each repository runs with its won dependencies, it seems that the simple Jenkins image is not able to download the needed requirements. Here the Jenkins image I used:</p>
<pre><code>FROM jenkins/jenkins:lts-alpine
USER root
RUN apk add python3 &amp;&amp; \
 python3 -m ensurepip &amp;&amp; \
 pip3 install --upgrade pip setuptools &amp;&amp; \
 if [ ! -e /usr/bin/pip ]; then ln -s pip3 /usr/bin/pip ; fi &amp;&amp; \
 if [[ ! -e /usr/bin/python ]]; then ln -sf /usr/bin/python3 /usr/bin/python; fi &amp;&amp; \
 rm -r /root/.cache
RUN pip install alpine
RUN apk add pkgconf
RUN apk add build-base
RUN apk add python3-dev
RUN apk -U upgrade
RUN apk add --no-cache libffi-dev openssl-dev
RUN apk add gcc musl-dev python3-dev libffi-dev openssl-dev cargo
RUN apk update
USER jenkins
</code></pre>
<p>For example, this image is not able to download <code>scipy</code> library, nor <code>blis</code>. Then I tried an ubuntu image by installing Jenkins, but I did not have any success deploying it.</p>
<p>By reading a bit more online, I have came to solutions that use Jenkins for pulling the other docker images and testing them accordingly. But I have always read that running docker in docker is not really a best practice.</p>
<p>In short, what is the best practice to test docker images in a Kubernetes environment with Jenkins? Is it possible to run an ubuntu image with jenkins inside so in case of a missing library I can always exec into the pod and <code>sudo apt-get install X</code> for the missing package? Lastly, if running docker in docker is not an anti-pattern in the end, how would you set up the testing?</p>
<p>note: each flask repository comes with their test suite that generates xml reports for junit to parse.</p>

purple_lolakos
<p>If you want your custom execution environment in Jenkins, then I would suggest to build your own Jenkins agent using <code>jenkins/agent</code> (or <code>jenkins/inbound-agent</code>) as the base image.</p>
<p>In case of running your Jenkins in Kubernetes, you can use <a href="https://github.com/jenkinsci/helm-charts" rel="nofollow noreferrer">Jenkins Helm Chart</a> (or Jenkins Operator) and <a href="https://github.com/jenkinsci/helm-charts/blob/main/charts/jenkins/values.yaml#L592" rel="nofollow noreferrer">modify the agent image</a> to your custom Jenkins agent image.</p>
