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.
Building custom images - Docker Tutorial
From the course: Docker: Build and Optimize Docker Images
Building custom images
- [Instructor] When you're working with Docker projects, it is a best practice to use custom images versus using the official images available on Docker Hub. You can use an official image as a base, but then build upon it to customize the contents of the image for your project's needs. In the GitHub repo for this course, I've created a simple Node.js app that just displays a Hello from Docker message in a web browser. This app listens on Port 3000. I have this project open in VS Code. To run this app, we need to build a custom image using the provided Dockerfile, which defines how the image should be built. Here's what each instruction does. The FROM instruction uses a lightweight node, Alpine 3.20 image, for a small, secure base. WORKDIR /app sets the working directory inside the container to app. The COPY instruction copies package.json and package-lock.json to the container. RUN npm ci installs dependencies exactly as specified in the lock file. COPY app copies the rest of the…