<p>I am trying to create a maven-based buildkit image for the jenkins agent.
If you create an image and run it as an agent, it takes infinite repetition.
I think the image is built incorrectly, but it asks to inspect the Dockerfile.</p>
<pre><code>FROM jenkins/inbound-agent:alpine as jnlp

FROM maven:3.6.3-jdk-11-slim as maven

RUN apt-get update &amp;&amp; \
    apt-get install -y \
        git \
        libfontconfig1 \
        libfreetype6

FROM moby/buildkit

COPY --from=jnlp /usr/local/bin/jenkins-agent /usr/local/bin/jenkins-agent
COPY --from=jnlp /usr/share/jenkins/agent.jar /usr/share/jenkins/agent.jar

ENTRYPOINT [&quot;/usr/local/bin/jenkins-agent&quot;]

</code></pre>
<p>When only the maven agent is created without the &quot;FROM moby/buildkit&quot; statement, it runs without problems.</p>

raboy
<p>Updated answer with a full example:</p>
<p>Your Dockerfile doesn't have references to the maven image.
If you need to have buildit in your final image you can install it by downloading from the GitHub or copying it from a docker image as you have for Jenkins agent.</p>
<p>I didn't test below docker file but hope you got the idea.</p>
<pre><code>FROM jenkins/inbound-agent:alpine as jnlp
FROM moby/buildkit as buildkit

FROM maven:3.6.3-jdk-11-slim

RUN apt-get update &amp;&amp; \
    apt-get install -y \
        git \
        libfontconfig1 \
        libfreetype6

COPY --from=buildkit /usr/bin/build* /usr/local/bin/
COPY --from=jnlp /usr/local/bin/jenkins-agent /usr/local/bin/jenkins-agent
COPY --from=jnlp /usr/share/jenkins/agent.jar /usr/share/jenkins/agent.jar

ENTRYPOINT [&quot;/usr/local/bin/jenkins-agent&quot;]
</code></pre>
