0

I am trying to run a ruby script for backend services by using docker run command.

  • Adding CMD ["./bin/ruby_code_name"] in Dockerfile
  • Running docker run -it --name=containerName --rm testimage command after building the image.

it shows the following error:

E, [2018-07-09T20:09:25.039697 #1] ERROR -- : [amqp] Detected TCP connection failure: Errno::ECONNREFUSED /usr/local/rvm/gems/ruby-2.1.9/gems/amqp-1.6.0/lib/amqp/session.rb:182:in `block in initialize': Could not establish TCP connection to 127.0.0.1:5672 (AMQP::TCPConnectionFailed) from /usr/local/rvm/gems/ruby-2.1.9/gems/amqp-1.6.0/lib/amqp/session.rb:796:in `call' from /usr/local/rvm/gems/ruby-2.1.9/gems/amqp-1.6.0/lib/amqp/session.rb:796:in `tcp_connection_failed' from /usr/local/rvm/gems/ruby-2.1.9/gems/amqp-1.6.0/lib/amqp/session.rb:639:in `unbind' from /usr/local/rvm/gems/ruby-2.1.9/gems/eventmachine-1.0.9/lib/eventmachine.rb:1468:in `event_callback' from /usr/local/rvm/gems/ruby-2.1.9/gems/eventmachine-1.0.9/lib/eventmachine.rb:193:in `run_machine' from /usr/local/rvm/gems/ruby-2.1.9/gems/eventmachine-1.0.9/lib/eventmachine.rb:193:in `run' from ./bin/ruby_code_name:216:in `<main>'

How can I configure amqp or rabbitmq or bunny to run the ruby script?

Cherry
  • 971
  • 1
  • 10
  • 20
  • Using 127.0.0.1 or `localhost` in a Docker context is almost always wrong; you need to configure some other name for the AMQP broker, depending on if it's running in another Docker container or somewhere else. – David Maze Jul 09 '18 at 21:45
  • It's NOT running in another docker container. It's running in my local machine. I added this as environmental variable `AMQP_RECEIVE_URL=amqp://guest:guest@rabbitmq`. But it does nothing. Do you have any idea? Thanks for your repsonse – Cherry Jul 10 '18 at 13:18

1 Answers1

0

It's working fine for me. All I had to do is: add this command CMD ["bundle", "exec", "ruby","filename"] into Dockerfile and add the envFile where I have added the AMQP variable value in docker run command

Cherry
  • 971
  • 1
  • 10
  • 20