Docker images play a pivotal role in the Docker ecosystem. In this article, we will cover an in-depth overview of Docker images, Docker hub and Docker images command.
As defined by Docker’s official documentation, “Docker provides the ability to package and run an application in a loosely isolated environment called a container. The isolation and security allow us to run many containers simultaneously on a given host. Containers are lightweight because they do not need the extra load of a hypervisor but run directly within the host machine’s kernel. This means we can run more containers on a hardware combination than virtual machines.”
What is a Docker Image?
Before we learn about containers, we need to first understand the ‘image’ term in Docker. If we look at the diagram above, the top layer of apps and libs/bins above the Docker daemon is encapsulated in the container. The app is packaged with libraries and binaries required by it. But how does Docker achieve this packaging?
Docker provides the facility to create a custom image on top of the Linux kernel with your app and its libraries. If we take this from an object-oriented programming point of view, an image is a class, where all the requirements are defined and declared. A container is an instance of the image. These images are stored somewhere in the cloud and pulled as needed.
List of Docker Image Commands
Docker uses a set of keywords to carry out these activities related to image and the list below shows all Docker image commands with their descriptions.
#docker build
To build an image from a Dockerfile.
docker build
Developers often use this command to create a Docker container based on their local files and folders.
Check how to build a Docker image from Dockerfile here.
#docker commit
To create a new image from a container’s changes.
docker commit <container_name>
#docker history
To show the history of an image.
docker history <container_name>
#docker images
To list images.
docker images
#docker import
To import the contents from a tarball to create a filesystem image.
docker import
#docker load
To load an image from a tar archive or STDIN.
docker load
#docker rmi
To remove one or more images.
docker rmi <container_name>
Tip: For more on Docker images, check our in-depth tutorials on how to update a Docker image and how to remove Docker images, including removing one image, dangling images, and how to remove all Docker images.
#docker save
To save images to a tar archive or STDOUT.
docker save <container_name>
#docker tag
To tag an image into a repository.
docker tag