- Lab
-
Libraries: If you want this lab, consider one of these libraries.
- Cloud

Building a Docker Image with Packer
Packer allows us to create machine images using a number of builders — including Docker images! Built _without_ the use of a Dockerfile, using Packer with Docker requires the use of simple scripts and some metadata changes to get everything up and running. In this lab, we'll do just that by creating a Docker image to deploy a Node.js application.

Lab Info
Table of Contents
-
Challenge
Refactor the Dockerfile
Packer provisions Docker images using the same provisioners as any other image. That said, not all steps in the build will work one-to-one.
Additionally, the follow Dockerfile instructions can be provided as metadata in the build itself:
USER
ENTRYPOINT
WORKDIR
EXPOSE
CMD
These will run as intended with a container launched from the image.
We'll refactor our template to use the
file
andshell
provisioners to create our script. -
Challenge
Write the Docker Builder Block
Write the builder block for the Docker builder, and add the relevant post-processors.
-
Challenge
Test the Build
- Validate the template.
- Test the build.
About the author
Real skill practice before real-world application
Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.
Learn by doing
Engage hands-on with the tools and technologies you’re learning. You pick the skill, we provide the credentials and environment.
Follow your guide
All labs have detailed instructions and objectives, guiding you through the learning process and ensuring you understand every step.
Turn time into mastery
On average, you retain 75% more of your learning if you take time to practice. Hands-on labs set you up for success to make those skills stick.