Docker Images Tutorial – Docker Image Repository & Commands
Keeping you updated with latest technology trends, Join DataFlair on Telegram
Today, we will see Docker Images tutorial. Moreover, we will look at Docker images and layers. Also, we will see Docker commands and Docker image repository. Along with this, we will look at how to download and display Docker images.
While it comes to images in Docker, everything is based on images. Well, a combination of a file system and parameters is what we call an image.
So, let’s start Docker Images tutorial.
2. What is Docker Image?
Simply put, images in Docker are the basis of containers. Also, we can say an ordered collection of root filesystem changes and the corresponding execution parameters for use within a container runtime is what we call an image. It typically contains a union of layered filesystems stacked on top of each other. However, an image does not have state and it always remains the same (never changes).
Recommended Reading – Best Docker Features
In other words, a file, comprised of multiple layers, which we use to execute code in a Docker container, is what we call Docker image. It is essentially built from the instructions for a complete and executable version of an application, that relies on the host OS kernel. While the user of Docker runs an image, that becomes one or multiple instances of that container.
3. Docker Images and Layers
Generally, there are multiple layers in a Docker image. Basically, to include system libraries, tools, and other files and dependencies for the executable code, a user composes every Docker image. It is possible to reuse static image layers for different projects by image developers. Since a user does not have to create everything in an image, reuse saves time.
A user can build one entirely from scratch if desired, even if most Docker images start with a base image. In the command line interface (CLI), each layer of a Docker image is viewable under /var/lib/docker/aufs/diff, or via the Docker history command). Docker shows all top-layer images, Like the repository, tags and file sizes, by default.
Also, a writable layer is created, when a new container is created from an image, which we knew as the container layer. Basically, it hosts all changes made to the running container. As its main job, it stores newly written files, modifications to existing files as well as newly deleted files. In addition, this layer also permits customization of the container.
4. Docker Image Repositories
In both private or public repositories, Docker users store images, and from there it can deploy containers, test images and share them. As we know, Docker Hub is a cloud-based registry service offered by Docker, which includes private and public image repositories. Also, it has Docker Trusted Registry, that adds image management as well as access control features.
While community images are images created by Docker users, official images have been produced by Docker. An example of an official Docker image is a CoScale agent that offers to monitor of Dockerized applications. And, datadog/docker-dd-agent is an example of a community Docker image, that is as Docker container for agents in the log management program Datadog.
By using the docker push command, a user can upload their own custom image to the Docker Hub. Moreover, Docker reviews the image and provides feedback for the image author before publishing, to ensure the quality of community images. However, the author of the image is responsible for updated, once it is published.
5. Docker Commands
There are several Commands that Docker CLI enables a user to use which customize Docker images. Some of them are:
- Docker history
This command shows the history of an image, which also includes changes made to it and its layers.
docker history [OPTIONS] IMAGE
- Docker update
This command permits a user to update the configuration of containers.
docker update [OPTIONS] CONTAINER [CONTAINER...]
- Docker tag
It creates a tag, like as target_image, that enables users to group as well as organize container images.
docker tag SOURCE_IMAGE[:TAG] TARGET_IMAGE[:TAG]
- Docker search
This command looks in Docker Hub, an image repository, for whatever the user needs.
docker search [OPTIONS] TERM
- Docker save
It permits a user to save images to an archive.
docker save [OPTIONS] IMAGE [IMAGE...]
- Docker rmi
It removes one or multiple images.
docker rmi [OPTIONS] IMAGE [IMAGE...]
- Docker image
It simply manages images
docker image COMMAND
- Docker image build
This command builds an image from a Dockerfile
docker image build [OPTIONS] PATH | URL |
- Docker inspect
In order to see the details of an image or container, we use it.
docker inspect Repository
- Displaying Docker Images
We can issue the following command, in order to see the list of images on the system.
- Downloading Docker Images
By using the Docker run command, we can download Images from Docker Hub.
docker run image
- Docker images -q
This command helps to return only the Image ids of the images.
Hence, we have seen whole about Docker Images and its commands. However, if you have any doubt, feel free to ask in the comment tab. We are happy to Help.
See also –