为什么舰队服务没有运行但 docker 命令运行了?

为什么舰队服务没有运行但 docker 命令运行了?

我有一个文件中的舰队服务nginx.service,我正尝试在 CoreOS 上启动它:

[Unit]
Description=nginx

[Service]
User=core
TimeoutStartSec=0
EnvironmentFile=/etc/environment

ExecStartPre=-/usr/bin/docker stop nginx
ExecStartPre=-/usr/bin/docker rm nginx

ExecStart=/usr/bin/docker run --rm --name nginx -v /home/core/nginx/conf:/etc/nginx/conf:ro -p 80:80 nginx:latest
#
ExecStop=-/usr/bin/docker stop nginx
ExecStopPost=-/usr/bin/docker rm nginx

Restart=always
RestartSec=10s

[X-Fleet]

当我用启动它时fleetctl start nginx.service,它没有显示任何错误,但是当我尝试访问该网站时,我在日志中看到了以下内容:

Aug 24 15:00:09 core-01 docker[2839]: 172.17.8.1 - - [24/Aug/2016:15:00:09 +0000] "GET / HTTP/1.1" 403 571 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36" "-"
Aug 24 15:00:09 core-01 docker[2839]: 2016/08/24 15:00:09 [error] 5#5: *1 directory index of "/usr/share/nginx/html/" is forbidden, client: 172.17.8.1, server: localhost, request: "GET / HTTP/1.1", host: "172.17.8.101"
Aug 24 15:00:09 core-01 docker[2839]: 2016/08/24 15:00:09 [error] 5#5: *1 open() "/usr/share/nginx/html/favicon.ico" failed (2: No such file or directory), client: 172.17.8.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "172.17.8.101", referrer: "http://172.17.8.101/"
Aug 24 15:00:09 core-01 docker[2839]: 172.17.8.1 - - [24/Aug/2016:15:00:09 +0000] "GET /favicon.ico HTTP/1.1" 404 571 "http://172.17.8.101/" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36" "-"

但是如果我从 fleet 文件启动 docker 命令:

/usr/bin/docker run --rm --name nginx -v /home/core/nginx/conf:/etc/nginx/conf:ro -p 80:80 nginx:latest

它正常运行并显示正确的页面。

我做错了什么以及如何解决?

相关内容