El servidor Docker y la configuración del contenedor se inician automáticamente.

1. La configuración del servicio Docker se inicia automáticamente

Ver servicios iniciados

systemctl list-units --type=service

Compruebe si está configurado para iniciarse al inicio

systemctl list-unit-files | grep enable

Configurar el inicio

systemctl enable docker.service

Desactivar el inicio

systemctl disable docker.service

2. Configuración del contenedor Docker para que se inicie automáticamente

Agregue --restart=always al iniciar

docker run -tid --name isaler_v0.0.11 -p 8081:8080 --restart=always -v /alidata/iDocker/run/projectImages/isaler/v0.0.11/log:/usr/local/tomcat/logs isaler_v0.0.11


Flag	Description
no		不自动重启容器. (默认value)
on-failure 	容器发生error而退出(容器退出状态不为0)重启容器
unless-stopped 	在容器已经stop掉或Docker stoped/restarted的时候才重启容器
always 	在容器已经stop掉或Docker stoped/restarted的时候才重启容器

Si el proyecto se ha ejecutado

如果已经启动的项目,则使用update更新:
docker update --restart=always 容器id

おすすめ

転載: blog.csdn.net/weixin_55127182/article/details/132359706
おすすめ