Docker is an open source container technology that can be used to build, publish and run applications. By using Docker images, users can download and install pre-built applications or container environments simply and quickly.
Docker images are composed of multiple layers (Layer), each layer contains a snapshot of the file system. When a user pulls a Docker image, they actually obtain all the layers of the image from the Docker Registry and combine them to build a complete Docker image.
So, where is the local storage location of the Docker image? This article will introduce it to you in detail.
- View the Docker image list
First, we need to view the current local Docker image list. Enter the following command in the terminal:
docker images
After execution, a list of all Docker images on the machine will be listed, including image ID, image name, image label, image size and other information. As shown in the figure below:
#As you can see from the above figure, each image has a unique ID, a name and some tags (also called versions). Among them, the REPOSITORY field represents the name of the image, the TAG field represents the label of the image, and the IMAGE ID field is the unique identifier of the image.
- View Docker image storage location
In Docker, each image is composed of multiple layers (Layer). Therefore, when a user downloads or builds a Docker image, all layers of the image are actually downloaded to local storage.
In the Linux system, the Docker image is actually stored in the /var/lib/docker
directory. Enter the following command in the terminal:
sudo ls -l /var/lib/docker/
After execution, the terminal will display a list of all files and folders in the /var/lib/docker/ directory. Among them, the /var/lib/docker/image
folder is the main location where Docker stores images. As shown in the figure below:
In the /var/lib/docker/image/overlay2/imagedb/content/sha256
directory, all existing The downloaded Docker image (named by the image ID), which is the storage location of all layers. In each image ID directory, there is a file named "real" or "diff", which represents the storage location of this layer.
- Confirm the storage location of the image layer
For each layer of the Docker image, its storage location can be confirmed by executing the following command:
docker history <image_name>:<tag>
For example, for the nginx image, executing the command:
docker history nginx:latest
will output the following results:
IMAGE CREATED CREATED BY SIZE COMMENT 84cf8d0a2e04 3 weeks ago /bin/sh -c #(nop) CMD ["nginx" "-g" "daemon… 0B <missing> 3 weeks ago /bin/sh -c #(nop) STOPSIGNAL SIGTERM 0B <missing> 3 weeks ago /bin/sh -c #(nop) EXPOSE 80 0B <missing> 3 weeks ago /bin/sh -c ln -sf /dev/stdout /var/log/nginx… 22B <missing> 3 weeks ago /bin/sh -c set -x && apt-get update && ap… 68.2MB <missing> 3 weeks ago /bin/sh -c #(nop) ENV NJS_VERSION=2.1.0.6 0B <missing> 3 weeks ago /bin/sh -c #(nop) ENV NGINX_VERSION=1.16.1 0B <missing> 4 weeks ago /bin/sh -c #(nop) LABEL maintainer=NGINX Do… 0B <missing> 4 weeks ago /bin/sh -c #(nop) CMD ["bash"] 0B <missing> 4 weeks ago /bin/sh -c #(nop) ADD file:7fbfce9f6a99e63a5… 63.2MB
Among them, the SIZE field of each layer indicates the actual space occupied by the layer. The first column of the output result of this command is the ID of each layer of the Docker image, which represents each layer of the image from top to bottom.
We can confirm the specific storage location of each layer based on the output of this command. For example, in the output of the above command, the last column is the description information of the layer, which includes the original command and parameters of the layer.
For the first layer of the nginx image (ID is "84cf8d0a2e04"), the CMD of this layer is "CMD ["nginx" "-g" "daemon..."", which means starting the nginx service; for the following Each layer contains other configurations or commands. Therefore, we can roughly guess where each layer of the Docker image is stored.
- Summary
With the above command, users can view the locally stored Docker image under the Linux system. The layer of the Docker image is stored in the /var/lib/docker/image/overlay2/imagedb/content/sha256
directory with the image ID as the folder name. Each layer is stored in a "real" or "diff" file respectively.
For the storage location of each layer of mirroring, you can view the storage location of the layer by executing the docker history
command and look for the description information of the layer in the output results to roughly guess the storage location of the layer.
When using Docker images and containers, understanding the storage location of Docker images can better manage local storage space, as well as backup and restore Docker images and containers.
The above is the detailed content of Check where the docker image is pulled and placed. For more information, please follow other related articles on the PHP Chinese website!

The methods of installing and using Docker on Ubuntu, CentOS, and Debian are different. 1) Ubuntu: Use the apt package manager, the command is sudoapt-getupdate&&sudoapt-getinstalldocker.io. 2) CentOS: Use the yum package manager and you need to add the Docker repository. The command is sudoyumininstall-yyum-utils&&sudoyum-config-manager--add-repohttps://download.docker.com/lin

Using Docker on Linux can improve development efficiency and simplify application deployment. 1) Pull Ubuntu image: dockerpullubuntu. 2) Run Ubuntu container: dockerrun-itubuntu/bin/bash. 3) Create Dockerfile containing nginx: FROMubuntu;RUNapt-getupdate&&apt-getinstall-ynginx;EXPOSE80. 4) Build the image: dockerbuild-tmy-nginx. 5) Run container: dockerrun-d-p8080:80

Docker simplifies application deployment and management on Linux. 1) Docker is a containerized platform that packages applications and their dependencies into lightweight and portable containers. 2) On Linux, Docker uses cgroups and namespaces to implement container isolation and resource management. 3) Basic usages include pulling images and running containers. Advanced usages such as DockerCompose can define multi-container applications. 4) Debug commonly used dockerlogs and dockerexec commands. 5) Performance optimization can reduce the image size through multi-stage construction, and keeping the Dockerfile simple is the best practice.

Docker is a Linux container technology-based tool used to package, distribute and run applications to improve application portability and scalability. 1) Dockerbuild and dockerrun commands can be used to build and run Docker containers. 2) DockerCompose is used to define and run multi-container Docker applications to simplify microservice management. 3) Using multi-stage construction can optimize the image size and improve the application startup speed. 4) Viewing container logs is an effective way to debug container problems.

Docker container startup steps: Pull the container image: Run "docker pull [mirror name]". Create a container: Use "docker create [options] [mirror name] [commands and parameters]". Start the container: Execute "docker start [Container name or ID]". Check container status: Verify that the container is running with "docker ps".

The methods to view Docker logs include: using the docker logs command, for example: docker logs CONTAINER_NAME Use the docker exec command to run /bin/sh and view the log file, for example: docker exec -it CONTAINER_NAME /bin/sh ; cat /var/log/CONTAINER_NAME.log Use the docker-compose logs command of Docker Compose, for example: docker-compose -f docker-com

You can query the Docker container name by following the steps: List all containers (docker ps). Filter the container list (using the grep command). Gets the container name (located in the "NAMES" column).

Create a container in Docker: 1. Pull the image: docker pull [mirror name] 2. Create a container: docker run [Options] [mirror name] [Command] 3. Start the container: docker start [Container name]


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

WebStorm Mac version
Useful JavaScript development tools

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SublimeText3 English version
Recommended: Win version, supports code prompts!