Reuse docker image across multiple Jenkins pipelines

  docker, jenkins, jenkins-pipeline

I am using Docker in my Jenkins pipeline, and setting it up with agent { dockerfile { ... } } command. This works for one repository, but I want to use the same container in another pipeline, with another repository.

I could just copy the Dockerfile to the other repository, but then presumably Jenkins would create a whole new (idential) Docker image. Is there any way to avoid this duplication?

I would rather avoid uploading my Dockerfile to Docker hub right now. Would a Jenkins shared library pipeline work? But I guess that is also overkill.

Source: Docker Questions

LEAVE A COMMENT