From the course: Docker Essential Training
Unlock the full course today
Join today to access over 24,900 courses taught by industry experts.
Multi-stage builds - Docker Tutorial
From the course: Docker Essential Training
Multi-stage builds
- [Instructor] Now that we know the basics of writing Dockerfiles, let's spend the next few sections learning some tips and tricks for making your images even better. The first feature we'll learn about is multi-stage builds. We know from our chapter on container images that container images can take up space, especially if they have a lot of layers. We've never really considered the size of our image, as we've been focused on getting our app working. If you run docker images my-image, like I did here, we can see that the image is actually quite large. Even though our app is really small, the Ubuntu-based image includes a lot of tools and utilities. These add up. I was curious about how much bigger our image is relative to our app, so I wrote a small script called size_diff.sh to compare the two. It's included in your exercise files, if you want to play around with it. As it happens our final image is almost 135,000 times…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
Introduction to Dockerfiles1m
-
(Locked)
The anatomy of a Dockerfile4m 37s
-
(Locked)
Sourcing other Docker images with FROM4m 32s
-
(Locked)
Building your first image3m 59s
-
(Locked)
Adding and copying files with COPY and ADD3m 51s
-
(Locked)
Updating the image5m 22s
-
(Locked)
Customizing your Docker image with RUN7m 46s
-
(Locked)
Starting your app with ENTRYPOINT9m 25s
-
(Locked)
"Starting" your app with CMD7m
-
(Locked)
Adding variables with ENV and ARG9m 39s
-
(Locked)
Other helpful Dockerfile commands5m 36s
-
(Locked)
Multi-stage builds9m 57s
-
(Locked)
Multi-platform images15m 10s
-
(Locked)
Multi-app images8m 8s
-
(Locked)
Challenge: Build and run your first image2m 1s
-
(Locked)
Solution: Build and run your first image5m 54s
-
-
-
-
-
-
-
-