Docker Layer Caching (DLC)

Learn how DLC can reduce build times on CircleCI, limitations, and best practices.

 

Welcome to the Docker Layer Caching (DLC) Course

In this course, we cover concepts regarding DLC. This training may be particularly useful for CircleCI customers who would like to minimize their use of DLC for building docker images.  

Who should take this course?

This course is designed for CircleCI developers using the cloud hosted solution. You should be familiar with managing source code in a VCS such as GitHub or Bitbucket; have a working knowledge of editing YAML files, and experience using command line utilities to automate builds and deploys for the technology stack at your organization. This course is intentionally code-agnostic, with an assumption that you have a clear understanding of the commands appropriate for your tooling, that you would use to build, test, and deploy projects. 

Duration: ~10 minutes

 

 

Concepts:

How Docker Layer Caching Works

Course SCORM: https://drive.google.com/file/d/1jjZkuO8j6C91NQvU8yYzhnTLS3jPbPfp/view?usp=share_link

Concepts covered in this lesson include:

  • Layering of a Docker file
  • Where new builds begin
  • Review of a Docker layer caching demo

 

Docker Layer Caching in CircleCI

 

Course SCORM: https://drive.google.com/file/d/16MKLXu7XEyBSZscwR90li9vVDqzTvtMu/view?usp=share_link

in this lesson, you will learn about:

  • Enabling Docker layer caching
  • Attaching a DLC volume to an executor
  • Attaching a DLC volume to multiple executors
  • Limitations of Docker layer caching

 

Caching from a Remote Registry

Course SCORM: https://drive.google.com/file/d/1nS_n0sBQ3QTixpns3A7dXHZ2Iw_GsVXe/view?usp=share_link

In this lesson, you will learn about:

  • Creating a cache
  • Saving cache to remote registry
  • Pulling cache from registry

 

Docker Layer Caching Best Practices

Docker Layer Caching Best Practices

Structuring Docker Layers

As we have already discussed, all steps following a change in your Docker file will need to be rebuilt and can not be pulled from a cache. In this example, the step containing your code is the step most likely to change. In this case “COPY app.py .”.  This means each time this file is built, that layer, and every layer below it, must be rebuilt. The more layers that need rebuilt, the longer your build takes and the more it costs. The code dependencies and requirements will not change nearly as often.

 

This means that it’s important to structure your Docker build in a way that takes the most advantage of your cache. In this example, we have moved the layer most likely to change farther down in the Docker file, increasing the number of layers that can be pulled from a cache. This reduces the build time and saves money.

 

General Resources:

Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Article is closed for comments.