如何在系统启动时自动启动 Docker 容器? [英] How do I make a Docker container start automatically on system boot?
本文介绍了如何在系统启动时自动启动 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 Compose 中是否也提供此功能?
If so, is this also available in Docker Compose?
推荐答案
是的,docker 有 重启策略,例如 docker run --restart=always
将处理这个问题.这也可以在 compose.yml 配置文件中作为 使用重启:总是
.
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屋!
查看全文