Images Management
An image can be used to create and run containers. It is like a template, containing instructions on how to build the container. Images are the starting point for any container related activity, and can be thought of as a snapshot in a virtual machine (VM) environment.
Building an image based on a Dockerfile
With the Dockerfile that we created in the last step, let’s build a container image:
docker build -t my-image .
You’ll see an output like this:
Sending build context to Docker daemon 10.95MB
Step 1/4 : FROM registry.access.redhat.com/ubi8/openjdk-11
latest: Pulling from ubi8/openjdk-11
396754cf27f9: Pull complete
41e1474940d5: Pull complete
fe52369f78c0: Pull complete
Digest: sha256:98c69a5b81bca0fe331100390c7357c69fd137e8a6228300eda820a0893a1be0
Status: Downloaded newer image for registry.access.redhat.com/ubi8/openjdk-11:latest
---> e502114b0d20
Step 2/4 : ADD target/lib/* /deployments/lib/
---> 47e879f30cec
Step 3/4 : ADD target/*-runner.jar /deployments/app.jar
---> 393bbade30ae
Step 4/4 : CMD ["java", "-jar", "/deployments/app.jar"]
---> Running in d09c7708954d
Removing intermediate container d09c7708954d
---> 87776d35fc85
Successfully built 87776d35fc85
Successfully tagged my-image:latest
Listing the available images
To see your just created image, just run:
docker image list
You’ll see at least these two outputs:
REPOSITORY TAG IMAGE ID CREATED SIZE
my-image latest 87776d35fc85 4 minutes ago 516MB
registry.access.redhat.com/ubi8/openjdk-11 latest e502114b0d20 2 months ago 505MB
Your image is the my-image
and the registry.access.redhat.com/ubi8/openjdk-11
is the image used to build yours.