是否可以重新创建或重新部署具有相同容器 ID 的 docker 容器?

Is it possible to re-create or re-deploy docker container with same container ID?

我将容器 ID 存储在我的数据库中,基于此我定期检查我的容器是否仍在 运行ning 或已停止使用 'Docker Inspect' 我在我的数据库中更新此信息。

如果我只想更新状态,但如果有人想更改环境,上面的方法就可以了。变量并使用 docker 运行 命令创建容器,然后生成一个新的容器 ID。

所以我的问题是是否可以使用之前的容器 ID 生成新的 docker 容器?

当您 运行 容器时,似乎没有 "manually" 设置 UUID 的选项。这是 Docker 守护程序负责的事情。

Container identification

The operator can identify a container in three ways:

| Identifier type       |                              Example value                        |
|===========================================================================================|
| UUID long identifier  | "f78375b1c487e03c9438c729345e54db9d20cfa2ac1fc3494b6eb60872e74778"|
| UUID short identifier | "f78375b1c487"                                                    |
| Name                  | "evil_ptolemy"                                                    |

The UUID identifiers come from the Docker daemon. If you do not assign a container name with the --name option, then the daemon generates a random string name for you. Defining a name can be a handy way to add meaning to a container. If you specify a name, you can use it when referencing the container within a Docker network. This works for both background and foreground Docker containers.