Best practices

Overview

Teaching: 15 min
Exercises: 20 min
Questions
  • Are there any practices I should avoid?

  • Are there practices I should try to follow?

  • How can I keep my images small?

  • How can I speed up iterative updates and testing?

Objectives
  • Learn some do’s and don’ts

  • Learn how to manage image sizes and avoid surprises

  • Learn how to use effectively use the build cache to speed up builds

Key Points

  • Use a Dockerfile

  • Use Trusted Images

  • Use versioned dependencies

  • Combine steps in a single RUN statement to reduce image size

  • Use && to catch errors in multi-step RUN statements

  • Use ordering to speed up rebuilds using the build cache

  • Use multi-stage builds