Docker image, container, warehouse concept and application of detailed _docker

Source: Internet
Author: User
Tags docker hub docker run

Docker image, container, warehouse concept

Docker mirroring

Docker mirroring (image) is similar to a virtual machine image, and can be interpreted as a read-only template for the Docker engine, including a file system.

For example, a mirror can fully contain the Ubuntu operating system environment, which can be called an Ubuntu mirror. Mirroring can also be installed with an Apache application (or other software) that can be referred to as an Apache image.

Mirroring is the foundation for creating Docker containers, with version management and incremental file systems, Docker provides a very simple mechanism for creating and updating existing mirrors. Users can download an already-done application image from the Internet and use it directly by command. In short, the application run is a need for the environment, and mirroring is to provide this environment.

Docker container

The Docker container (Container) is similar to a lightweight sandbox (because Docker is a virtual technology based on the Linux kernel, so consumes very few resources), Docker uses containers to run and isolate applications.

A container is a running instance of an application created from a mirror that can be started, started, stopped, and deleted, and these containers are isolated from each other and are not visible to each other.

It's okay. Each container is viewed as a simplified version of the Linux system environment (including root permissions, process space, user space, and network space), and an application box packaged with the application running in it.

The mirror itself is read-only. When a container starts from a mirror, Docker creates a writable layer at the top of the mirror, and the mirror itself remains unchanged. As with the ISO system, ISO has not changed much.

Docker Warehouse

The Docker Warehouse (Repository) is similar to the Code warehouse, which is the place where Docker centrally store mirrored files.

There are times when you see data that confuse Docker warehouses with Registered Servers (Registry) and are not strictly differentiated. In fact, a registered server is the place where warehouses are stored, often with multiple warehouses. Each warehouse focuses on a certain type of mirror, often including multiple mirror files, through different tags (tag) to differentiate. For example, a warehouse that hosts Ubuntu operating system mirrors, called the Ubuntu Warehouse, may include different versions of mirrors such as 14.04,12.04.

The Docker warehouse is divided into two forms, public and private, privately, depending on whether the stored mirror is publicly shared or not.

At present, the largest public warehouse is the Docker Hub, storing a large number of mirrors for users to download. Domestic public warehouses, including Docker pool, can provide a stable domestic visit. If users do not want to share their own mirrored files publicly, Docker also supports creating a private warehouse that can only be accessed by users within the local network.

When a user creates his or her own mirror, it can be uploaded to the specified public or private warehouse using push. The next time the user uses the mirror on another machine, just pull it from the warehouse.

The following article describes the basic commands for the above concepts

Docker basic commands for mirroring, containers, warehouses


1. Get Mirror

$ Docker Pull for registration server, 5000 for port number, Ubuntu for warehouse name, 14.04 for mirror and version number

2. View mirror Information

Lists all mirrors that are already present on the local host


Change changes information

$ docker Tag ubuntu:latest

000 for mirror ID, show details of this mirror

$ Docker Inspect 000

3. Search for Mirrors

$ docker Search MySQL (output information includes mirror name, description, star, whether it was officially created, whether it was created automatically)

4. Remove Mirror

$ docker RMI

Note: The mirrored file cannot be deleted by default when there is a container created by the mirror, so it is best to delete all containers that depend on the mirror before removing the mirror, please do not use forced deletion.

5. Create a mirror

There are three different ways:

Created based on a container that already has mirrors

$ docker commit-m "Add new Image"-a "" 000 (container ID) test (new image name)

Import based on local template

$ Cat Ubuntu-14.04-x86_64-minimal.tar.gz | Docker import-ubuntu:14.04

Create based on Dockerfile

6. Save the Mirror

$ docker Save-o Ubuntu_14.04.tar ubuntu:14.04

7. Load Mirror Like

$ Docker Load--input Ubuntu_14.04.tar


Docker Load < Ubuntu_14.04.tar

8. Upload Image

$ docker Push User/test:latest

User users need to register at the Dockerhub site


A container is a running instance of a mirror, but it has an extra writable layer

1. Create a container

$ docker create-it ubuntu:12.04

2. Create and start containers

$ docker run-it Ubuntu:12.04/bin/bash

3. Guardian State operation

$ docker run-d ubuntu:12.04

4. View container Information


View termination Status

5. Get the output information of the container


Cet is the first three characters of the container ID

6. Termination of containers

$ docker Stop CET

7. Start the container

$ Docker Start CET

8. Restart Container

$ docker Restart CET

9. Enter the container

Attach command

$ docker attach nostalgic (nostalgic is the name of Docker)

Disadvantage: All windows synchronized display

EXEC command

-Docker exec-it 243 ... /bin/bash (243 ... for Docker ID)

Nsenter command

1. Find the PID

$ pid=$ (docker-pid 243 ...)

2. Through the PID link container

$ nsenter--target $PID--mount--uts--ipc--net--pid

10. Delete Container

$ docker RM [-f-l-V] CET

-F forced to terminate and delete

-L Delete the container's links, and keep the container

-V Deleting a mounted data volume

$ Docker Export CET >test.tar

12. Import container (Import container snapshot to local mirror library)

$ Cat Test.tar | Docker import-test/ubuntu:v1.0

Re-specify the mirror name for Ubuntu, v1.0 version number

Docker load can also import mirrored storage files to the local mirror library, and he has the advantage of importing a mirrored snapshot file that will lose all history and metadata information.

Note: container migration can be achieved by exporting containers and importing containers (copying files)


A warehouse is a place where mirrors are centrally located, and there are many warehouses on a registered server, and many mirrors in a warehouse.

1. Login

$ docker Login

2. Basic operation

Find, Upload, download

3. Automatically create

4. View Mirrors


5. Update the Mirror label

$ docker Tag ubuntu:12.04

Change the previous mirror to ubuntu:12.04

6. Create a private warehouse

$ docker run-d-P 5000:5000-v/opt/data/registry:/tmp/registryregistry

Automatically downloads and launches the Registry container, creates a local private warehouse service, and the default warehouse ship's container is/tmp/registry, which can be stored on the specified path via the-v argument

7. Manage Private Warehouse Mirroring

Suppose the private warehouse address is and the port is 5000,

$ docker Tag ubuntu:14.04

Change the label signature

$ docker Push

Push mirrors will automatically push to the Address Machine

$ Curl Http://

To see if a test mirror is included in the warehouse

Docker Pull

Download a mirror on any machine that has access to a Address

Thank you for reading, I hope to help you, thank you for your support for this site!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.