有新镜像版本时如何更新Docker镜像?

How to update Docker image when there is new image version?

我目前是运行官方ghostDocker镜像,并使用这个镜像搭建了几个容器

如果我想更新我的 Docker 图像,我只需使用命令:

docker pull ghost
docker restart oldcontainer 

有效吗?

。更新映像不会影响从该映像构建的映像,并且当然不会影响从该映像创建的已经 运行 个容器。

一个可能的工作流程是……。像这样:

  1. 拉取新版本的基础镜像
  2. 在图像之上构建您自己的图像的新版本
  3. 从新建的镜像中销毁并重新创建您自己的容器

A docker restart does a docker stop (or docker kill if the stop times out), which puts a container in an exit status, followed by a docker start,启动 same 容器。

在该过程中根本没有检测到图像可能已更改的事实。

删除并使用所有正确的参数进行完整的 docker 运行 会在图像更改时生效。参见“How to upgrade docker container after its image changed