Docker container (Container)

Creative Commons License Copyright: Attribution, allow others to create paper-based, and must distribute paper (based on the original license agreement with the same license Creative Commons )

Copyright, without permission, is prohibited reprint


chapter


Container (container) is a running instance Docker image, similar to the relationship between the executable file and process, Docker containers engine is equivalent to the system platform.

Run container

Use docker runthe command management and operation of the vessel.

Examples

[root@qikegu ~]# docker run -it --rm busybox
/ #
/ #
/ #
/ #
/ # exit

This command will run busybox image, then the system enters busybox shterminal.

exitExit command shell, the container itself will also stop running. Can also be used ctrl + p + q, you can exit the shell, the vessel will continue to run.

The container list

docker psCommand to list the container on the system.

Simple usage

docker ps

Common options

  • -a, --allShow all of the container (including the already stopped)

return value

The printing system in the container.

example

Print system currently running container.

[root@qikegu ~]# docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
6dabe342ab99        busybox             "sh"                19 seconds ago      Up 18 seconds                           jovial_swirles

Show all containers (including already stopped)

[root@qikegu ~]# docker ps -a
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                         PORTS               NAMES
6dabe342ab99        busybox             "sh"                     5 minutes ago       Up 5 minutes                                       jovial_swirles
0f191fd7d469        busybox             "sh"                     26 minutes ago      Exited (0) 26 minutes ago                          hopeful_lalande
8ae26063af0b        hello-world         "/hello"                 About an hour ago   Exited (0) About an hour ago                       nostalgic_jepsen
4e80cdf55081        busybox             "sh"                     About an hour ago   Exited (0) About an hour ago                       heuristic_euler
2190b6af6286        hello-world         "/hello"                 2 hours ago         Exited (0) 2 hours ago                             pensive_ganguly
cd5d988325ff        jenkins             "/bin/tini -- /usr/l…"   40 hours ago        Exited (130) 40 hours ago                          awesome_heyrovsky
053eaa5cc8e5        hello-world         "/hello"                 41 hours ago        Exited (0) 41 hours ago                            gifted_booth
b6f8c654159a        2bcb04bdb83f        "/bin/bash"              5 weeks ago         Exited (127) 5 weeks ago                           competent_khorana
8703a9083c4a        2bcb04bdb83f        "/bin/bash"              5 weeks ago         Exited (0) 5 weeks ago                             cocky_engelbart

docker history

This command displays create a mirror of history.

Simple usage

docker history IMAGE

Common options

  • The IMAGE - Specifies image name / ID.

return value

Display historical images.

example

The Create history busybox image.

[root@qikegu ~]# docker history busybox
IMAGE               CREATED             CREATED BY                                      SIZE                COMMENT
64f5d945efcc        10 days ago         /bin/sh -c #(nop)  CMD ["sh"]                   0B
<missing>           10 days ago         /bin/sh -c #(nop) ADD file:e36dd1822f36a8169…   1.2MB

Tutorial mentioned are typical command usage, other usage, can be used docker help commandto view, for example:docker help rmi

Docker containers and host

Docker Engine is cross platform, as long as the Docker installed on the host, docker mirror will be able to run in the host, no matter what their specific system environment Yes. For example: a nginx Docker image can be run on any system installed docker, whether it is Linux or windows, etc. This is a great advantage, which means the deployment of applications will be greatly simplified.

Guess you like

Origin blog.csdn.net/weixin_43031412/article/details/94550932