Attending this event?
View analytic
Thursday, August 31 • 2:30pm - 3:15pm
Simplify your Jenkins Projects with Docker Multi-Stage Builds

Sign up or log in to save this to your schedule and see who's attending!

When building Docker images we often use multiple build steps and Dockerfiles to keep the image size down.  Using multi-stage Docker builds we can eliminate this complexity, bringing all of the instructions back into a singe Dockerfule while sill keeping those images nice and small.

One of the most challenging things about building images is keeping the image size down. Each instruction in the Dockerfile adds a layer to the image, and you need to remember to clean up any artifacts you don’t need before moving on to the next layer. To write a really efficient Dockerfile, you have traditionally needed to employ shell tricks and other logic to keep the layers as small as possible and to ensure that each layer has the artifacts it needs from the previous layer and nothing else.  It was actually very common to have multiple Jenkins pipeline steps and/or projects with unique Dockerfiles for different elements of the final build.  Maintaining multiple sets of instructions to build your image is complicated and hard to maintain.

With multi-stage builds, you use multiple FROM statements in your Dockerfile. Each FROM instruction can use a different base, and each of them begins a new stage of the build. You can selectively copy artifacts from one stage to another, leaving behind everything you don’t want in the final image and simplifying the both the Dockerfile and Jenkins configurations needed to produce your images.

avatar for Eric Smalling

Eric Smalling

Solution Architect, Docker Inc.
Eric has 25 years of professional experience in enterprise software development and architecture, including build, test and deployment automation. He has been practicing DevOps concepts since long before the term was coined. On practically every project throughout his career, he has worn multiple hats: developer, automated testing evangelist, version control administrator and build system engineer. | | Eric has been a continuous integration advocate and implementer for nearly a decade, he is active in the Jenkins community and is responsible for implementing and administering a large-scale Jenkins cluster at one of the... Read More →

Thursday August 31, 2017 2:30pm - 3:15pm
Nob Hill A-D
Feedback form isn't open yet.