???? ????????? ????????? ?????

???? ????????? ????????? ?????

Docker ?? Restart Policy ??????? ???? ?????? ????????????? ?????? ???????????????? ???? ????, ???? ?????????????????? ???? ????? ?? ????? ?????????????? ???? ????? ??? ???????????????? ??????? ???? ?????? ????? ???? ??? ???????? ?????? ????? ?????? Docker ?? ???????? ????? Restart Policy ????? ?????? ????

Restart Policy ?? ??? ????

Docker ?? restart policies ????? ???? ??? ???? ????? ??????????? ??? ??????? ???? ???:

?????? ????? ??? ???? ???? ????? ??? ???? ????? ? YAML ???? ??????? ??? declaratively ??????? ???? ????? Docker Compose, Docker Swarm, ?? Kubernetes ?? ????

Docker ?? ????? ?????? Restart Policy ????

  1. always
  2. unless-stopped
  3. on-failure

???? ???? ????? ????? ????? ???????? ???? ????

?. always Restart Policy

always Restart Policy ??? ???? ??????????? ?????? ?????? ???? ???? ???? ???? ???? ???? ??? ???? ??? ???? ?????, ???? ??????? ??? ?? ????? ??????????? ??? ??????

????? ???????? ????? ???? ???? ????????? ?????? ???? ???? --restart always ????? ????? ??? ????


restart always


mycontainer ????? ???? ???? ????????? ???? ???

alpine ???? ??????? ??? ???? ???? sh ??? ??????

--restart always ?????? ??????? ??? ???? ?????, ?????? ??? ???? ??? ?? ???

??????????? ????? ?????? ????? ps -elf ??? ???? ?????? ?? ??? PID 1 ???? ?????? ????? exit ?????? ????? ??????????? ???? ?????

??????????? ???? ????? ??? docker ps ????? ??????????? ?????? ??????

?????? ?? ??????????? ???? ?????? ?? Docker ??? ???? ???? ?????? ??? docker inspect ????? ??? ??? ???, RestartCount ???? ????? ?????? ????? ??? ??????? ???? ???????

docker inspect mycontainer --format '{{.RestartCount}}'



?. unless-stopped Restart Policy

unless-stopped ??????? always ?? ??? ??? ???, ??? ???????? ?? ??? Docker daemon ????????? ??? ????????? ?????? ????? ????????????? ???? ???, ?????? ?????? ??????? ???? ??? ??? ?????? ???? ???? ???

???? ???? ????????? ??????, ???? always ??? ?????? unless-stopped ????? ?????


unless stopped


???? ??????????? ?????? ????? docker ps ???? ??????????? ?????? ??? ???? ????? ???? ?????????? ?????? ???? docker stop ????? ????? ???? ???? ???? ??? ???? ????????? ???? ?????

always-example ??????????? ??????? ???? ??????

unless-stopped-example ??????????? ???? ???????? ???? ????


?. on-failure Restart Policy:

Docker ?? on-failure ????? ???? ??????? ????? ?? ????????? ????????? ?????? ????? ???? ??? ??????? ???? ???? on-failure ??????? ????????? ???? ?????? ???? ???? ??? ???:

  • ??? ??????????? non-zero exit code ?? ???? ???, ????? ??? ???????????????? ???? ???? ????
  • ??? Docker daemon ????????? ???? ??????????? ??????? ???? ???, ????? ??????? ??????????? ???? ???????? ???????

?? ????? ???? ??????? ????? ???? ????? ?????????????? ???? ??????? ?????? ?? self-healing ?????? ?????? ??? ???? ??? ??? ??????????? ????????????? ???? ??? (???? exit code 0 ?????), ????? ??? ??????? ???? ??? ???


??????? ? ??? ?????? ???? ???? ????? ??????? ???? ??????? ???? ????? ???? ??????? ????



Hasanur Seam

Software Engineer | NodeJs | Angular | Java(Spring boot) | MongoDB | PostgreSQL | MSc Uni-Bremen

1 周

Thanks for sharing

要查看或添加评论,请登录

Ruhul Amin的更多文章