Building Images
In Foundation, you ran containers from images someone else built. In this section, you build your own image, from your own Next.js app.
What You Will Learn
By the end of this section, you will be able to:
- Write a Dockerfile for a real Next.js app, and explain what each line does
- Build, run, and push your own image to Docker Hub
- Make that image much smaller using a multi-stage build
- Build an image that runs on both Intel and ARM machines
- Keep unnecessary files out of your image with
.dockerignore
Pages in This Section
Writing a Dockerfile
Package a Next.js app into an image, instruction by instruction.
Build, Run & Push
Turn the Dockerfile into a real image, run it, and publish it to Docker Hub.
Smaller Images
Cut your image down using a multi-stage build and Next.js’s standalone output.
BuildKit & Multi-Arch
Build faster, and build images that run on both amd64 and arm64 machines.
.dockerignore
Keep the wrong files out of your build — and out of your final image.
You need a Next.js app for this section. If you do not have one handy, the first page shows the one command to create one.
Next → Writing a Dockerfile
Last updated on