Docker: Add a restart policy to a container that was already created

后端 未结 3 1281
灰色年华
灰色年华 2020-11-30 18:04

I see that Docker has added something called restarting policies to handle restart of containers in case of, for instance, reboot.

While this is very useful, I see t

3条回答
  •  有刺的猬
    2020-11-30 18:28

    There're two approaches to modify RestartPolicy:

    • Find out the container ID, stop the whole docker service, modify /var/lib/docker/containers/CONTAINER_ID/hostconfig.json, set RestartPolicy -> Name to "always", and start docker service.
    • docker commit your container as a new image, stop & rm the current container, and start a new container with the image.

提交回复
热议问题