我有如下systemd脚本:
[Unit]
Description=Hub docker container
After=docker.service
[Service]
User=root
ExecStart=/home/hub/hub.sh
ExecStop=/bin/docker stop hub
ExecStopPost=/bin/docker rm hub
[Install]
WantedBy=multi-user.target
运行命令:systemctl start/stop hub 没有问题。我还使用 systemctl enable hub 来创建符号链接。为什么在重新启动整个笔记本电脑后我的服务没有启动? 我遵循了docker指南,以便Docker在重新启动时启动,但由于某种原因我的容器没有启动。 我的脚本缺少哪个字段吗?
我在我的 ExecStart 中使用的命令是“/home/hub/hub.sh”脚本:
docker run --net=host --restart=always --name hub -t hub
重启后,当我输入systemctl status hub时,会出现以下情况:
● hub.service - Hub docker container
Loaded: loaded (/etc/systemd/system/hub.service; enabled; vendor preset: disabled)
Active: inactive (dead)
--restart unless-stopped
。 - user6455909