<h2>Problem</h2>
<p>I would like to do the following:</p>
<ol>
<li>Create an image with Trivy and Docker installed</li>
<li>Run the container on Kubernetes</li>
<li>Schedule a CRON job to pull all images from a container registry and to scan them, and output the results to stdout</li>
</ol>
<h2>Question</h2>
<p>Is there a smart way to do this? Can you even install docker within a docker container?</p>

<p>I ended up doing the following:</p>
<ol>
<li>Creating an image with <a href="https://github.com/aquasecurity/trivy" rel="nofollow noreferrer">Trivy</a> and <a href="https://github.com/containers/skopeo" rel="nofollow noreferrer">Skopeo</a> installed</li>
<li>Downloading the docker images with Skopeo
<ul>
<li>skopeo copy --src-creds=user:password --dest-compress --src-tls-verify=false docker://myrepo.com/mynamespace/ubuntu:latest oci:ubuntu</li>
</ul>
</li>
<li>Scanning the image
<ul>
<li>trivy image --input ubuntu</li>
</ul>
</li>
</ol>
<p>An alternative to Skopeo would be to use the <a href="https://docs.docker.com/registry/spec/api/" rel="nofollow noreferrer">Registry HTTP API</a> to download images as suggested by David Maze.</p>
