![在 Ubuntu 服务器 16.04 上,docker-compose 导致 systemd 失败](https://linux22.com/image/693502/%E5%9C%A8%20Ubuntu%20%E6%9C%8D%E5%8A%A1%E5%99%A8%2016.04%20%E4%B8%8A%EF%BC%8Cdocker-compose%20%E5%AF%BC%E8%87%B4%20systemd%20%E5%A4%B1%E8%B4%A5.png)
我有一个 docker-compose 项目,我想通过 systemd 进行控制。我在 systemd 中有下一个文件。
[Unit]
Description=My Server container
Requires=docker.service
After=docker.service
[Service]
Restart=always
ExecStart=/usr/local/bin/docker-compose -f /home/adminuser/project/docker-compose.yml up
ExecStop=/usr/local/bin/docker-compose -f /home/adminuser/project/docker-compose.yml stop
[Install]
WantedBy=multi-user.target
我已经在 Amazon Web Services 中的实例中成功测试了此文件。每次我重新启动时,我的服务都会运行,但实际上我需要在安装了 Ubuntu Server 16.04 的 Server hp proliant microserver gen8 中实现该服务,不幸的是,当我重新启动服务器时,该服务无法启动我的 docker 项目。
这是显示错误。
● backend.project.service - My Server container
Loaded: loaded (/etc/systemd/system/backend.sssirsa.service; enabled; vendor preset: enabled)
Active: failed (Result: start-limit-hit) since mar 2016-11-15 09:38:26 CST; 1h 17min ago
Process: 3469 ExecStop=/usr/local/bin/docker-compose -f /home/adminuser/project/docker-compose.yml stop (code=exited, status=1/FAILURE)
Process: 3461 ExecStart=/usr/local/bin/docker-compose -f /home/adminuser/project/docker-compose.yml up (code=exited, status=1/FAILURE)
Main PID: 3461 (code=exited, status=1/FAILURE)
nov 15 09:38:26 PROJECT systemd[1]: backend.project.service: Unit entered failed state.
nov 15 09:38:26 PROJECT systemd[1]: backend.project.service: Failed with result 'exit-code'.
nov 15 09:38:26 PROJECT systemd[1]: backend.project.service: Service hold-off time over, scheduling restart.
nov 15 09:38:26 PROJECT systemd[1]: Stopped My Server container.
nov 15 09:38:26 PROJECT systemd[1]: backend.project.service: Start request repeated too quickly.
nov 15 09:38:26 PROJECT systemd[1]: Failed to start My Server container.
nov 15 09:38:26 PROJECT systemd[1]: backend.project.service: Unit entered failed state.
nov 15 09:38:26 PROJECT systemd[1]: backend.project.service: Failed with result 'start-limit-hit'.
我尝试了很多解决方案,例如:
- 将我的用户 adminuser 添加到 docker 组
- 将 chmood 777 添加到服务文件
- 在init.d目录下添加
但没有什么能帮助我解决我的问题
我希望有人能帮助我解决我的问题。