Difference between container and image


The Linux kernel is layer 0, so no matter how you run Docker, it runs on top of the kernel layer. This Docker image, which is a read-only image at layer 1, cannot be modified or save state.

A Docker image can be built on top of another Docker image, and this cascading relationship can be multi-layered. The image layer of the first layer is called the base image (Base Image), and the images of other layers (except the topmost layer) are called the parent image (Parent Image). These images inherit all the properties and settings of their parent image and add their own configuration in the Dockerfile.

Docker images are identified by their image ID. Image ID is a 64-character hexadecimal string. But when we run an image, usually we don't use the image ID to refer to the image, but the image name. To list all available images locally, you can use the command

# docker images
Images can be released as different versions, this mechanism we call tags.
Write the picture description here

As shown in the figure above, the neo4j image has two versions: the lastest version and the 2.1.5 version.

You can use the pull command to add the specified label:

# docker pull ubuntu:14.04
# docker pull ubuntu:12.04
Second, Docker container

Docker container can be created using the command:

# docker run imagename
It adds a writable layer on top of all mirror layers. This writable layer has processes running on the CPU and has two different states: Running and Exited. This is the Docker container. When we start the container with docker run, the Docker container enters the running state, and when we stop the Docker container, it enters the exiting state.

When we have a running Docker container, from running to stopped, all changes we make to it are permanently written to the container's filesystem. Remember that changes to the container are written to the container's filesystem, not to the Docker image.

We can start multiple Docker containers with the same image, and these containers are all active after they are started, and they are still isolated from each other. The changes we make to one of the containers are limited to that container itself.

If the underlying image of the container is modified, the currently running container will not be affected, and automatic updates will not occur.

If we want to update a container to a new version of its image, we have to be careful to make sure we are building the data structures in the correct way, otherwise we could end up losing all the data in the container.

A 64-character hexadecimal string to define the container ID, which is a unique identifier for the container. The interaction between containers is identified by the container ID. Since the characters of the container ID are too long, we usually only need to type the first 4 characters of the container ID. Of course, we could also use the container name, but it's obviously easier to use a 4-character container ID.

So the container is started based on the image.

Reprinted from: CSDN senior architect http://blog.csdn.net/chszs/article/details/48252799

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326475608&siteId=291194637