<ul>
<li>I have tests that I run locally using a <code>docker-compose</code> environment. </li>
<li><strong>I would like to implement these tests as part of our CI using Jenkins with Kubernetes on Google Cloud</strong> (following <a href="https://cloud.google.com/solutions/jenkins-on-kubernetes-engine-tutorial" rel="nofollow noreferrer">this setup</a>). </li>
<li><a href="https://stackoverflow.com/q/50197692/1561176">I have been unsuccessful</a> because <a href="https://stackoverflow.com/a/31381323/1561176">docker-in-docker does not work</a>.</li>
</ul>

<p>It seems that right now there is no solution for this use-case. I have found other questions <em>related</em> to this issue; <a href="https://stackoverflow.com/q/37214628/1561176">here</a>, and <a href="https://stackoverflow.com/q/48995717/1561176">here</a>.</p>

<p>I am looking for solutions that will let me run <code>docker-compose</code>. I have found <a href="https://stackoverflow.com/a/35830359/1561176">solutions for running <code>docker</code></a>, but not for running <code>docker-compose</code>.</p>

<p>I am hoping someone else has had this use-case and found a solution.</p>

<hr>

<p><strong>Edit:</strong> Let me clarify my use-case:</p>

<ol>
<li>When I detect a valid trigger (ie: push to repo) I need to start a new job.</li>
<li>I need to setup an environment with multiple dockers/instances (docker-compose).</li>
<li>The instances on this environment need access to code from git (mount volumes/create new images with the data).</li>
<li>I need to run tests in this environment.</li>
<li>I need to then retrieve results from these instances (JUnit test results for Jenkins to parse).</li>
</ol>

<p><strong><em>The problems I am having are with 2, and 3.</em></strong> </p>

<p>For 2 there is a problem running this in parallel (more than one job) since the docker context is shared (docker-in-docker issues). If this is running on more than one node then i get clashes because of shared resources (ports for example). <em>my workaround is to only limit it to one running instance and queue the rest (not ideal for CI)</em></p>

<p>For 3 there is a problem mounting volumes since the docker context is shared (docker-in-docker issues). I can not mount the code that I checkout in the job because it is not present on the host that is responsible for running the docker instances that I trigger. <em>my workaround is to build a new image from my template and just copy the code into the new image and then use that for the test (this works, but means I need to use docker cp tricks to get data back out, which is also not ideal)</em></p>

Inbar Rose
<p>I think the better way is to use the pure Kubernetes resources to run tests directly by Kubernetes, not by <code>docker-compose</code>.</p>

<p>You can convert your docker-compose files into Kubernetes resources using <code>kompose</code> <a href="https://kubernetes.io/docs/tools/kompose/user-guide/" rel="nofollow noreferrer">utility</a>.</p>

<p>Probably, you will need some adaptation of the conversion result, or maybe you should manually convert your docker-compose objects into Kubernetes objects. Possibly, you can just use <a href="https://kubernetes.io/docs/concepts/workloads/controllers/jobs-run-to-completion/" rel="nofollow noreferrer">Jobs</a> with multiple containers instead of a combination of deployments + services. </p>

<p>Anyway, I definitely recommend you to use Kubernetes abstractions instead of running tools like <code>docker-compose</code> inside Kubernetes.</p>

<p>Moreover, you still will be able to run tests locally using Minikube to spawn the small all-in-one cluster right on your PC.</p>
