This one had me scratching my head for a while so I thought I’d write up the solution.
Usually, the 502 error signifies that you haven’t exposed the appropriate port in your Dockerfile - i.e. the Downstream server is complaining that it can’t connect to the upstream server. However, in this instance I had exposed the port for my Sinatra app. I noticed in the AWS logs that the Docker container was starting correctly and listening on tcp://localhost:3000 and this is where the issue is - you need to bind to 0.0.0.0 rather than localhost.
# app.rb... require ‘sinatra' set :bind, ‘0.0.0.0’ # THIS IS REQUIRED! get ‘/hello’ do “Success" end
Just add the bind command above and the 502 issue will disappear. Hope this helps someone.