docker image retention (built via dockerfiles)

121 views
Skip to first unread message

Lukas Winkler

unread,
Mar 15, 2018, 9:04:35 AM3/15/18
to Jenkins Users
Hi,

I want to setup a jenkinsfile building a git project and running tests in various environments, preferably docker (multiple gcc versions, clang, ...). My approach was to simply setup agents and connect them via ssh and install docker on them. The jenkinsfile will have a parallel section listing all the environments (from differnt dockerfiles) and what commands to run in them to run the tests). The build images would be cached and reruns would be decently fast and I would probably be happy with the results.

However now I am looking at the possibility of space issues with all those docker images beeing generated. The tags for those images are currently based on the SHA1 hash of the dockerfile and as I understand it will be based on a hash out of the dockerfile and the full project name in the future. I could simply delete (docker system prune -a) images periodically, but that leaves a sour taste in my mouth due to it forcing rebuilds of actual in use containers on one hand and beeing noticable in build logs tempering with build statistics.

I know that jenkins supports build discarder properties. Can something be patched in that would extend those properties to docker images beeing build?
Or maybe someone has an idea on how I can modify my setup to not run into those issues?

BR
Lukas

Morten Bjoernsvik

unread,
Mar 16, 2018, 8:00:17 PM3/16/18
to Jenkins Users
Hi Lucas

This is exactly the use case of a private docker registry like Nexus3. https://www.sonatype.com/nexus-repository-oss

You can build to what ever layer of readiness you need and then push it to the registry, then clean everything, then next time you need to build/run a container you just pull it from the registry.
No intermediate layers, no need to cache anything locally.

If you like to learn about how to optimize you docker workflow, You may look at https://fabric8.io, (which integrates Gogs, Jenkins and nexus).

--
MortenB

Lukas Winkler

unread,
Apr 10, 2018, 2:35:47 PM4/10/18
to Jenkins Users
Hi Morten,

sadly that would only move the problem from the local nodes to the nexus repository as there is no 'auto purge the oldest x images' option in nexus as far as I can tell.

BR
Lukas
Reply all
Reply to author
Forward
0 new messages