如何使Docker容器在系统启动时自动启动? [英] How do I make a Docker container start automatically on system boot?

查看:111
本文介绍了如何使Docker容器在系统启动时自动启动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有一个要运行的Docker容器,然后可以调用

Supposed I have a Docker container that I want to run, then I can call

$ docker run ...

一切都很好。如果系统崩溃并重新启动,是否有内置的方式来运行容器,使其能够自动重新启动?

and everything is fine. Is there a built-in way to run a container in a way that it will be restarted automatically, if the system crashes and reboots?

如果这样,是否也可用

推荐答案

是的,Docker具有重启策略,例如 docker run --restart = always 这样的处理策略。也可以在 compose.yml配置文件中作为<$ c使用$ c>重启:总是。

Yes, docker has restart policies such as docker run --restart=always that will handle this. This is also available in the compose.yml config file as restart: always.

这篇关于如何使Docker容器在系统启动时自动启动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆