Building An Image
Part of the Introduction to Docker section of Coddy's Terminal journey — lesson 22 of 40.
Once you have a Dockerfile, docker build turns it into an image. The -t flag gives the new image a name (tag), and the . tells Docker to use the current directory as the build context:
docker build -t myimage .Docker runs each Dockerfile instruction in order, printing a Step line for each one, and finishes with:
Successfully built ...
Successfully tagged myimage:latestAfter this, myimage shows up in docker images and you can run it like any other image.
Challenge
EasyWrite a Dockerfile with the single line FROM alpine, then build it into an image tagged mybox.
Cheat sheet
Build a Docker image from a Dockerfile using docker build. The -t flag sets the image name/tag, and . specifies the build context (current directory):
docker build -t myimage .After a successful build, the image appears in docker images and can be run like any other image.
Try it yourself
This lesson includes a short quiz. Start the lesson to answer it and track your progress.