Search code examples
ruby-on-railsdockerredisportsidekiq

How to configure sidekiq&redis without using docker-compose for rails?


I want to implement sidekiq to my rails app. I successfully create image and container. But when i try to execute job container in application can't find redis. How i can connect my-app container (which has it's own IP:port) with redis container (which has it's own IP:port).

I think the problem hides in sidekiq.rb. But I'm not sure

sidekiq_config = { url: "<container url>" }

Sidekiq.configure_server do |config|
  config.redis = sidekiq_config
end

Sidekiq.configure_client do |config|
  config.redis = sidekiq_config
end

I want to run 2 containers : my-app & redis. In my-app container sidekiq should know how to ping redis container.

PS My ̶r̶e̶l̶i̶g̶i̶o̶n̶ mentor do not allow me use docker-compose so it's pretty tricky


Solution

  • I found out that we can easily connect 2 containers with docker by using --link

    sudo docker run --name my-application --link my-redis-container:redis
    

    This Link was helpful for me. And here we don't actually need to use docker-compose