- Lab
- A Cloud Guru
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.
Path 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.
What's a lab?
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.
Provided environment for hands-on practice
We will provide the credentials and environment necessary for you to practice right within your browser.
Guided walkthrough
Follow along with the author’s guided walkthrough and build something new in your provided environment!
Did you know?
On average, you retain 75% more of your learning if you get time for practice.