zoukankan      html  css  js  c++  java
  • Docker commands

    老文章,草稿箱放了好久,放出来

    Docker commands

    1. Image vs Container

    An instance of an image is called a container. You have an image, which is a set of layers as you describe. If you start this image, you have a running container of this image. You can have many running containers of the same image.

    You can see all your images with docker images whereas you can see your running containers with docker ps (and you can see all containers with docker ps -a).

    So a running instance of an image is a container.

    2. docker create <image_id>
    docker create 命令为指定的镜像(image)添加了一个可读写层,构成了一个新的容器。注意,这个容器并没有运行.

    3. docker start <container_id>
    Docker start命令为容器文件系统创建了一个进程隔离空间。注意,每一个容器只能够有一个进程隔离空间。

    docker pause <container-id>
    docker pause命令则不一样,它利用了cgroups的特性将运行中的进程空间暂停。

    docker stop <container-id>
    docker stop命令会向运行中的容器发送一个SIGTERM的信号,然后停止所有的进程。
    Stop a running container (send SIGTERM, and then SIGKILL after grace period) [...] The main process inside the container will receive SIGTERM, and after a grace period, SIGKILL. [emphasis mine]

    docker kill <container-id>
    docker kill 命令向所有运行在容器中的进程发送了一个不友好的SIGKILL信号。
    ill a running container (send SIGKILL, or specified signal) [...] The main process inside the container will be sent SIGKILL, or any signal specified with option --signal. [emphasis mine]

    4. docker run <image_id>
    docker run = docker create + docker start

    5. docker ps
    docker ps 命令会列出所有运行中的容器。这隐藏了非运行态容器的存在.

    docker ps -a
    docker ps –a命令会列出所有的容器,不管是运行的,还是停止的。

    6. docker images
    docker images命令会列出了所有顶层(top-level)镜像。

    docker images -a
    列出所有的镜像,也可以说是列出了所有的可读层。如果你想要查看某一个image-id下的所有层,可以使用docker history来查看。

    7. docker rm <container_id>
    docker rm命令会移除构成容器的可读写层。注意,这个命令只能对非运行态容器执行。

    docker rmi <image-id>
    docker rmi 命令会移除构成镜像的一个只读层。你只能够使用docker rmi来移除最顶层(top level layer)(也可以说是镜像),你也可以使用-f参数来强制删除中间的只读层。

    8. docker commit <container-id>
    将容器的可读写层转换为一个只读层,这样就把一个容器转换成了不可变的镜像
    It can be useful to commit a container’s file changes or settings into a new image. This allows you to debug a container by running an interactive shell, or to export a working dataset to another server. Generally, it is better to use Dockerfiles to manage your images in a documented and maintainable way.

    9. docker exec <running_container_id>
    docker exec 命令会在运行中的容器执行一个新进程。

  • 相关阅读:
    Linux中大括号{}的应用
    shell script编程(1)>>学生成绩管理系统
    不同版本的Linux防火墙关闭和开启
    shell script的执行方式区别
    包管理介绍(DPKG,APT,RPM,YUM,DNF)
    MBR与GPT,BIOS与UEFI..总结
    Windows10下安装Ubuntu的错误总结
    学生管理系统及票务管理系统总结
    python 3.x和python 2.x下的换行问题
    输出整数各位数字
  • 原文地址:https://www.cnblogs.com/tedzhao/p/15475434.html
Copyright © 2011-2022 走看看