在不关闭容器的情况下更新容器的重启策略

docker update --restart=always container_name

容器重启策略

启动容器,指定重启策略:

docker run -d --restart unless-stopped redis

更新容器的重启策略:

sudo docker container update --restart no CONTAINER

容器的 restart policy:

  • no: 不自动重启
  • no-failure: 失败时(non-zero exit code)重启
  • always:总是重启,如果是人工停止,那么在 Docker daemon 重启时,容器也会重启
  • unless-stopped:和 always 类似, 除了容器手工或者其他方式停止。Docker daemon 在重启时不会重启容器

导出镜像到 tar 包

docker save -o /path/to/image.tar image:1.0.0

从 tar 包加载镜像

docker load -i path/to/image.tar

docker 镜像重命名

通过 tag 命令:

docker tag old_name new_name