使用docker和SQS的AWS Beanstalk上的Sinatra应用程序

我已经构build了一个简单的sinatra应用程序,用于侦听本地主机上的POST请求(包含来自AWS SQS的消息),并configuration了一个dockerfile以便于部署。

西纳特拉:

set :environment, 'staging' set :bind, 'localhost' set :port, '80' before do request.body.rewind @request_payload = JSON.parse request.body.read end post '/' do # do stuff with payload end 

Dockerfile:

 #https://dockerfile.github.io/#/ruby FROM dockerfile/ruby # Install dependencies RUN apt-get update RUN apt-get install postgresql-common postgresql-9.3 libpq-dev -y # Copy the Gemfile and Gemfile.lock into the image to cache bundle install # Temporarily set the working directory to where they are WORKDIR /tmp ADD ./Gemfile Gemfile ADD ./Gemfile.lock Gemfile.lock RUN bundle install # Copy code into the image ADD . /code WORKDIR /code # Open port 80 EXPOSE 80 # Clean up RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* # Default runtime command CMD /code/launcher.rb 

但是我在日志文件中得到这些错误:

 ------------------------------------- /var/log/nginx/error.log ------------------------------------- 2014/07/11 20:54:33 [error] 9023#0: *11 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 127.0.0.1, server: , request: "POST / HTTP/1.1", upstream: "http://127.0.0.1:12569/", host: "localhost" ------------------------------------- /var/log/docker ------------------------------------- 2014/07/11 20:54:33 Can't forward traffic to backend tcp/172.17.0.8:80: dial tcp 172.17.0.8:80: connection refused ------------------------------------- /var/log/aws-sqsd/default.log ------------------------------------- 2014-07-11T21:19:35Z http-err: d35bffd4-5c0b-4979-b046-5b42c7a990c0 (6) 502 - 0.023 ------------------------------------- /var/log/nginx/access.log ------------------------------------- 127.0.0.1 - - [11/Jul/2014:21:19:35 +0000] "POST / HTTP/1.1" 502 172 "-" "aws-sqsd/1.1" ------------------------------------- /var/log/docker-ps.log ------------------------------------- 'docker ps' ran at Fri Jul 11 21:11:52 UTC 2014: CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES f3d8a8a3ffb6 aws_beanstalk/current-app:latest /bin/sh -c /code/bui About a minute ago Up About a minute 0.0.0.0:12529->80/tcp backstabbing_pare 

有任何想法吗? 我认为它与港口有关。 我已经尝试过与别人没有成功…

set :bind, 'localhost'指令是冲突。 由于POST请求来自docker集装箱以外,Sinatra正在拒绝连接。

Interesting Posts