更新Docker的容器为自动启动

Published on Aug. 22, 2023, 12:10 p.m.

借助docker update就可以更新了

docker update –restart=unless-stopped 0576df221c

0576df221c是容器id

restart参数

no
Do not automatically restart the container. (the default)

on-failure
这个也不错
Restart the container if it exits due to an error, which manifests as a non-zero exit code.

always
Always restart the container if it stops. If it is manually stopped, it is restarted only when Docker daemon restarts or the container itself is manually restarted.

unless-stopped
建议使用这个
Similar to always, except that when the container is stopped (manually or otherwise), it is not restarted even after Docker daemon restarts.

官方文档
https://docs.docker.com/config/containers/start-containers-automatically/#restart-policy-details

Tags: