I have a docker container with an sinatra app inside, and another container with an node.js app. They are both linked through Fig. In my sinatra app I am making a HTTP Post request to the node.js app. For that I am using the Faraday gem.
My questions is now how can I make a HTTP request to another linked container.
Here's my fig.yml
db:
image: mongo:2.6.7
command: --smallfiles
api:
build: ./api
command: bundle exec rackup -p 3000
volumes:
- ./api:/code
ports:
- "3000:3000"
links:
- db
- flickrcrawler
flickrcrawler:
build: ./flickr-crawler
ports:
- "3100:3100"
links:
- db
and here's the method in the sinatra app I use to make a HTTP request with farady:
def crawler_call(url, tags)
tags.each do |t|
conn = Faraday.new(url: url) do |faraday|
faraday.request :url_encoded
faraday.response :logger
faraday.adapter Faraday.default_adapter
end
conn.post "#{t}"
end
end
what would I pass this method as url parameter?
You would use the name of the service in your fig.yml, in this case I think you're calling it flickrcrawler. So something like http://flickrcrawler:3100.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With