我尝试使用chat.service单元文件在CoreOS上启动一个服务,但失败了:
// chat.service
[Unit]
Description=ChatApp
[Service]
ExecStartPre=-/usr/bin/docker kill simplechat1
ExecStartPre=-/usr/bin/docker rm simplechat1
ExecStartPre=-/usr/bin/docker pull jochasinga/socketio-chat
ExecStart=/usr/bin/docker run -p 3000:3000 --name simplechat1 jochasinga/socketio-chatfleetctl list-units显示:
UNIT MACHINE ACTIVE SUB
chat.service cfe13a03.../<virtual-ip> failed failed但是,如果我将chat.service更改为:
// chat.service
[Service]
ExecStart=/usr/bin/docker run -p 3000:3000 <mydockerhubuser>/socketio-chat一切都很顺利。fleetctl list-units显示:
UNIT MACHINE ACTIVE SUB
chat.service 8df7b42d.../<virtual-ip> active running使用我得到的编辑journalctl -u chat.service:
Jun 02 00:02:47 core-01 systemd[1]: Started chat.service.
Jun 02 00:02:47 core-01 systemd[1]: chat.service: Main process exited, code=exited, status=125/n/a
Jun 02 00:02:47 core-01 docker[8924]: docker: Error response from daemon: failed to create endpoint clever_tesla on network brid
Jun 02 00:02:47 core-01 systemd[1]: chat.service: Unit entered failed state.
Jun 02 00:02:47 core-01 systemd[1]: chat.service: Failed with result 'exit-code'.
Jun 02 00:02:58 core-01 systemd[1]: Stopped chat.service.
Jun 02 00:03:08 core-01 systemd[1]: Stopped chat.service.我在第一个chat.service单元文件中做错了什么?如有任何指导,将不胜感激。
在Mac上运行迷航版CoreOS (稳定版)。
发布于 2016-06-01 19:43:59
您的ExecStartPre=命令中似乎没有停靠子命令。你是想用pull吗?
为该单位阅读日记应能获得更多信息:journactl -u chat.service
发布于 2016-06-02 04:03:37
在使用@Rob建议和一些研究查看了日志之后,看来docker无法在端口3000处创建端点,因为在操作系统上,该端口上有一个正在运行的对接进程。
只要用docker stop <processname>停止进程,用fleetctl start chat重新启动就可以解决问题。
https://stackoverflow.com/questions/37577005
复制相似问题