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.
Figlet software + Ubuntu base image -> New Image named figlet
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)
Install figlet software and its dependencies.
apt-get install figlet
Verify if the software is installed correctly on the container.
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 :)
Top comments (0)