Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The relationship between container and image in Docker [easy to understand]

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

What is the relationship between containers and mirrors in docker?

Recently learned docker, most people feel that container and mirror learning is a bit vague.

Especially mirror and container, feel completely inseparable, so learn here, and then summarize it, easy to learn later.

Here's my summary of the mirror hierarchy:

VM/Host--> Operating System (e.g. centos)--> Image img (including complete systems such as linux (ubuntu), mysql, apache, nginx, etc.). Mirrors consist of layers of system files.) Install--> Create Container--> Create App (APP).

A complete docker consists of the following parts:

DockerClient

Docker Daemon

Docker Image

DockerContainer

What to fix: Container--> Mirrors-->tar files

Time to test environment recovery: tar--> Mirrors--> Containers

The difference between mirror and container: mirror can be understood as java class, container can be understood as java object. i.e. mirror: Java class; container: Java object.

Many objects can be created through classes, that is, many containers can be created by mirroring.

In addition:

Docker has three parts: image + container + repository.

docker container = image + readable layer

Containers are instantiated from mirrors.

Simply put, a mirror is a file and a container is a process.

Containers are created on the basis of mirrors, i.e. processes in containers depend on files in mirrors.

Docker mirroring is similar to virtual machine mirroring. Is a read-only template, a separate file system that contains the data needed to run the container and can be used to create new containers.

Docker uses containers to run apps: docker containers are running instances created by docker images.

Docker containers are similar to virtual machines and can perform tasks including starting, stopping, deleting, etc. Each container is isolated from each other. A container runs a specific application, containing the code and required dependencies for that application. Think of a container as a simple version of linux environment (including root privileges, process space, user space, network space, etc.) and the applications running in it.

In Docker's lifecycle, the two most core parts are images and Containers.

Mirrors work as containers.

During the running process of Kubernetes Engine, changes are made based on the original image, such as installing programs, adding files, or committing them to become images.

For example, an image can contain a complete ubuntu operating system environment with mysql or other applications installed.

docker image is actually composed of a system file layer by layer, this hierarchical file system is called UnionFS( Union file system unified file system), the image can be built based on dockerfile, dockerfile is a description file, which contains several secret commands, each command will create a new hierarchy of the underlying file system.

Docker provides a simple mechanism for creating images or updating existing images. Users can even download an already made mirror from someone else and use it directly. (Mirrors are read-only and can be understood as static files)

Containers are dynamic relative to mirroring, and containers create a writable hierarchy as the top layer at startup.

docker create: adds a read-write layer to the specified image to form a new container;

Docker repository: docker repository concept is easy to understand if you use git and github. Docker repository concept is similar to git.

docker repository is used to contain the location of the image, docker provides a register to store multiple repositories, each repository can contain multiple images with different tags,

The default repository used in docker operations is the docker hub public repository.

The repository supports operations similar to git, where users create their own image and then use the push command to upload it to a public or private repository. This way, the next time you want to use this image on another machine, you just need to pull it from the repository.

----------------

Links:

About docker command: www.runoob.com/docker/docker-rmi-command.html

https://blog.csdn.net/qq_40722827/article/list/2

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report