惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
Docker
人人都是产品经理
人人都是产品经理
小众软件
小众软件
博客园 - Franky
WordPress大学
WordPress大学
Jina AI
Jina AI
Google DeepMind News
Google DeepMind News
I
InfoQ
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
F
Fortinet All Blogs
博客园 - 【当耐特】
IT之家
IT之家
G
Google Developers Blog
J
Java Code Geeks
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
云风的 BLOG
云风的 BLOG
Recent Announcements
Recent Announcements
有赞技术团队
有赞技术团队
V
Visual Studio Blog
U
Unit 42
阮一峰的网络日志
阮一峰的网络日志
月光博客
月光博客
GbyAI
GbyAI
雷峰网
雷峰网

博客园 - ted

低代码 产品的核心价值 如何判断需求的优先级 以组件为基础,基于功能扩展的前端架构 演进中的架构 康威定理 技术解耦和团队解耦 SSL的那些事——三 SSL的那些事_二 Xamarin 技术解析 Javascript Promises 介绍 Javascript的模块化编程 UI 设计概念介绍 Head First iOS Programming 一个Web页面的问题分析 QCon杭州2012技术开发大会感受 Ajax请求与浏览器缓存 Java中的一些基础概念 你了解Java中String的substring函数吗?
Docker commands
ted · 2021-10-28 · via 博客园 - ted

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

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 命令会在运行中的容器执行一个新进程。