我有一个sinatra API服务器,我可以在端口9292上成功运行,我希望在容器中运行。
我创建了一个Dockerfile,其中包含以下内容:
FROM ruby:2.2.0
RUN apt-get update -qq && \
apt-get install -y build-essential libpq-dev nodejs --no-install-recommends && \
rm -rf /var/lib/apt/lists/* && \
mkdir /myapp
WORKDIR /myapp
ADD . /myapp
RUN bundle install
EXPOSE 9292
CMD bundle exec rackup config.ru
构建映像后,我运行以下命令来启动容器:docker run -it -p 9292:9292 --rm api-server
我确认该应用已启动并正在运行,并提供了其他详细信息:
Listening on localhost:9292, CTRL+C to stop
尽管如此,我无法从服务器返回任何结果。有关为什么我无法访问容器的任何想法?我正在使用Docker 1.9.1运行Ubuntu 15.10
答案 0 :(得分:2)
我能够通过在瘦服务器上将主机指定为0.0.0.0来解决此问题。我的Dockerfile命令现在读取为:“t3" : "Miles",
“t8" : "Running",
“t2" : "6517.8432",
“t7" : "good",
“t6" : "",
“t1" : "2015-12-14",
"locations" : [
{
"timestamp" : "2015-11-12"
},
{
"longitude" : "-122.092223"
},
{
"latitude" : "37.34229154"
},
{
"timestamp" : "2015-11-12"
},
{
"longitude" : "-122.14944148"
},
{
"latitude" : "37.37778312"
},
{
"timestamp" : "2015-11-12"
},
{
"longitude" : "-122.14968145"
},
{
"latitude" : "37.3780272"
},
{
"timestamp" : "2015-11-12"
},
{
"longitude" : "-122.14990349"
},
{
"latitude" : "37.37828075"
},
{
"timestamp" : "2015-11-12"
},
{
"longitude" : "-122.15010976"
},
{
"latitude" : "37.37854172"
}
],
“t9" : "4",
“t5" : "Test123"