Pranava S Balugari
Posted on September 2, 2020
Let's take a close look at how to interactively build a docker image from base ubuntu image. We will use docker commands to create our custom image.
- Interactively launch BASH shell under Ubuntu Base image, Update apt-get, install figlet and its dependencies using apt-get, and then save the image.
e.g.
Figlet software + Ubuntu base image -> New Image named figlet
Prerequisites:
Ensure the Docker engine is installed on your machine
Fetch the base image and connect to the container.
docker run -it ubuntu
Next, Update apt-get update and its dependencies (with in the docker container)
apt-get update
Install figlet software and its dependencies.
apt-get install figlet
Verify if the software is installed correctly on the container.
figlet DEV.TO
If your output matches the above image, exit the container (Ensure you copy the container id)
Now run docker commit command with the container id saved in the previous step.
// Works even if you mention initial chars of container id
docker commit cbe1bc
Now look at all the images
docker images
undefined undefined cbe1bc519023 39 hours ago 98MB
ubuntu latest 4e2eef94cd6b 13 days ago 73.9MB
Rename the image created with a readable name
docker tag cbe1bc519023 figlet
Now look at all the images again
docker images
figlet latest cbe1bc519023 39 hours ago 98MB
ubuntu latest 4e2eef94cd6b 13 days ago 73.9MB
That is all :) Our custom image is ready to be pushed to docker hub and used by the community.
Note: Didn't cover the docker push and pull commands for the custom image created. That's for another day :)
...
Posted on September 2, 2020
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.