我试图通过调用以下命令来设置带有docker映像的本地dbpedia聚光灯服务器:
sudo docker run -i -p 2222:80 dbpedia/spotlight-english spotlight.sh
图像运行,当提示sudo docker ps
时,我得到了这个图像:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
02282289ae64 dbpedia/spotlight-english "/bin/sh" About a minute ago Up About a minute 0.0.0.0:2222->80/tcp sleepy_meninsky
但是当我发送以下简单请求时:
curl http://0.0.0.0:2222/rest/annotate?text=COOPER+Has+the+FBI+said+anything+about+a+reward+or+anything+%5C%3F+Because+there+was+that+there+was+a+reward+for+finding+her&confidence=0.5
或什至设置了标头的人:
curl -X POST http://localhost:2222/rest/annotate -H 'accept: application/json' -H 'content-type: application/x-www-form-urlencoded' --data-urlencode "text=President Obama called Wednesday on Congress to extend a tax break for students included in last year's economic stimulus package, arguing that the policy provides more generous assistance" --data-urlencode "confidence=0.35"
我遇到相同的错误:
curl: (56) Recv failure: Connection reset by peer
有人可以帮忙吗?这与我运行docker时对sudo的需求有关吗?
感谢您的时间和精力。
答案 0 :(得分:1)
在https://github.com/dbpedia-spotlight/spotlight-docker/blob/master/v1.0/english/Dockerfile检查Spotlight的Dockerfile,它没有配置入口点。
请在docker命令的末尾添加spotlight.sh,例如:
docker run -d -p 2222:80 dbpedia / spotlight-english spotlight.sh
另外,也许您想使用-d参数而不是交互模式-i将其作为服务运行。
祝一切顺利
答案 1 :(得分:1)
感谢Sandro指出了在运行docker时需要运行spotlight.sh
以及非常有用的-d
标志的原因,但是使docker工作并停止返回curl错误56的原因是根据需要指示了--restart unless-stopped
标志here
为我运行这项工作:
sudo docker run -itd --restart unless-stopped -p 2222:80 dbpedia/spotlight-english spotlight.sh
显然,如果该标志关闭,则docker将会关闭。我个人还没有观察到通过ssh运行ubuntu 18.04上的行为,但是当我决定将docker本地安装在mac机上时,映像不会保持运行一分钟以上。添加此标志可使Spotlight请求在两种环境下都能正常工作。
希望这可以帮助其他面临相同问题的人。