From the course: Docker: Build and Optimize Docker Images

Unlock this course with a free trial

Join today to access over 24,900 courses taught by industry experts.

Solution: Optimizing a Dockerfile

Solution: Optimizing a Dockerfile - Docker Tutorial

From the course: Docker: Build and Optimize Docker Images

Solution: Optimizing a Dockerfile

(soft upbeat music) - [Instructor] For this challenge, you are tasked with optimizing a Dockerfile to reduce the number of layers when building the image. Let's walk through how I'd solve this challenge. In Dockerfile.optimize, I asked you to combine run instructions that are related to each other. You should have had two run instructions in the end. Steps four through nine all have separate run instructions that can be combined. First, I'm going to combine the run instructions for installing dependencies, clearing the Alpine cache and installing Nodemon. I'm placing these on separate lines indicated by a backslash for better readability. For good measure, I'm also going to update the comment to list everything this one run command is doing. The second run instruction will include the user and group commands. I'll add a backslash after the creation of the app group and put the instruction to create the application user on the next line. Then I'll add another backslash and put the…

Contents