title: docker + rails + redis - rescue workers are not running
body: <p>I've created a docker environment that creates 3 images: rails, postgresql and redis. It has been working quite well but I have found that my redis image does not seem to have any workers running.</p>
  
  <h2>Docker Info</h2>
  
  <p>My docker-compose.yml is as follows</p>
  
  <pre><code>web:  
    build: .
    command: bundle exec unicorn -p 3000 -c config/unicorn.rb
    volumes:
      - .:/fitmo
      - ../fitmo-core:/fitmo-core
    ports:
      - "3000:3000"
    links:
      - db
      - redis
    environment:
      - REDIS_URL=redis://redis:6379
  
  db:
    build: ./db/docker-files
    ports:
      - "5432"
  
  redis:  
    image: redis:2.8
    ports:
      - "6379"
  </code></pre>
  
  <h2>Resque Config</h2>
  
  <pre><code>require 'resque'
  require 'resque-scheduler'
  require 'resque_scheduler/server'
  require 'appsignal/integrations/resque'
  require 'yaml'
  
  if Rails.env.test?
    require 'mock_redis'
    $redis = MockRedis.new
  else
    uri = URI.parse(ENV['REDIS_URL'])
    $redis = Redis.new(host: uri.host, port: uri.port, password: uri.password)
  end
  
  Resque.redis = $redis
  Resque.schedule = YAML.load_file(File.join(Rails.root, 'config/resque_schedule.yml'))
  
  Resque.before_fork do
    defined?(ActiveRecord::Base) and
      ActiveRecord::Base.connection.disconnect!
  end
  
  Resque.after_fork do
    defined?(ActiveRecord::Base) and
      ActiveRecord::Base.establish_connection
  end
  
  module Resque
  
    def queued_jobs
      queues = Hash.new
      Resque.queues.each do |queue|
        jobs = []
        Resque.peek(queue, 0, 5000).each do |job|
          jobs.push({klass: job['class'], args: job['args']})
        end
        queues[queue] = jobs
      end
      queues
    end
  
    def queued?(klass, *args)
      queued_jobs.select do |job|
        job[:klass] == klass.to_s &amp;&amp; job[:args] == args
      end.any?
    end
  
    def enqueue_once(klass, *args)
      enqueue(klass, *args) unless queued?(klass, *args)
    end
  
  end
  </code></pre>
  
  <h2>Ruby Gems</h2>
  
  <p>The following are the relevant gems being used. The commented out versions are the latest versions of the gems but I don't think this is an issue as the current versions are working fine in Heroku environments. I've also include rescue mailer and scheduler for thoroughness. They are not in play for the question</p>
  
  <pre><code>gem 'redis',            '3.0.7'         #'~&gt; 3.2.0'
  gem 'resque',           '~&gt; 1.25.2'     #'~&gt; 1.25.2'
  gem 'resque_mailer',    '~&gt; 1.0.1'      #'~&gt; 2.2.7'
  gem 'resque-scheduler', '~&gt; 2.5.5'      #'~&gt; 4.0.0'
  </code></pre>
  
  <h2>Testing Info</h2>
  
  <p>I have confirmed that redis is accessible from the web container by telnetting to host redis on port 6379. I've also output the value of Rescue.info which shows that there are items queued but now workers running</p>
  
  <pre><code>resque info: {:pending=&gt;1, :processed=&gt;0, :queues=&gt;2, :workers=&gt;0, :working=&gt;0, :failed=&gt;0, :servers=&gt;["redis://redis:6379/0"], :environment=&gt;"development"}
  </code></pre>
  
  <p>I'm stuck at this point as I'm not sure how to get the workers running. Any suggestions?</p>