Sidekiq throws scheduler error when starting Rails application

The details:

Docker version:

Client:
 Version:      17.03.0-ce
 API version:  1.26
 Go version:   go1.7.5
 Git commit:   60ccb22
 Built:        Thu Feb 23 10:40:59 2017
 OS/Arch:      darwin/amd64

Server:
 Version:      17.03.0-ce
 API version:  1.26 (minimum version 1.12)
 Go version:   go1.7.5
 Git commit:   3a232c8
 Built:        Tue Feb 28 07:52:04 2017
 OS/Arch:      linux/amd64
 Experimental: true

Rails: 5.0.0.1
Postgres:9.6.0
Redis: 3.2.4

The issue:

I’m having problems with sidqkiq not starting up when I run docker-compose up. It’s spitting out the following errors in my console:

sidekiq_1  | 2017-03-15T23:23:24.309Z 1 TID-gsmrzwufk INFO: Booting Sidekiq 4.2.3 with redis options {:url=>"redis://redis:6379/"}
sidekiq_1  | 2017-03-15T23:23:24.786Z 1 TID-gsmrzwufk INFO: Running in ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-linux]
sidekiq_1  | 2017-03-15T23:23:24.786Z 1 TID-gsmrzwufk INFO: See LICENSE and the LGPL-3.0 for licensing details.
sidekiq_1  | 2017-03-15T23:23:24.786Z 1 TID-gsmrzwufk INFO: Upgrade to Sidekiq Pro for more features and support: http://sidekiq.org
sidekiq_1  | 2017-03-15T23:23:24.794Z 1 TID-gsmrzwufk INFO: Loading Schedule
sidekiq_1  | 2017-03-15T23:23:24.794Z 1 TID-gsmrzwufk INFO: Schedule empty! Set Sidekiq.schedule
sidekiq_1  | 2017-03-15T23:23:24.795Z 1 TID-gsmrzwufk INFO: Schedules Loaded
sidekiq_1  | 2017-03-15T23:23:24.797Z 1 TID-gsmrzwufk WARN: {"context":"Exception during Sidekiq lifecycle event.","event":"startup"}
sidekiq_1  | 2017-03-15T23:23:24.797Z 1 TID-gsmrzwufk WARN: TypeError: can't dup NilClass
sidekiq_1  | 2017-03-15T23:23:24.798Z 1 TID-gsmrzwufk WARN: /usr/local/bundle/gems/sidekiq-scheduler-2.0.19/lib/sidekiq-scheduler/schedule.rb:126:in `dup'
sidekiq_1  | /usr/local/bundle/gems/sidekiq-scheduler-2.0.19/lib/sidekiq-scheduler/schedule.rb:126:in `block in prepare_schedule'
sidekiq_1  | /usr/local/bundle/gems/sidekiq-scheduler-2.0.19/lib/sidekiq-scheduler/schedule.rb:125:in `each'
sidekiq_1  | /usr/local/bundle/gems/sidekiq-scheduler-2.0.19/lib/sidekiq-scheduler/schedule.rb:125:in `prepare_schedule'
sidekiq_1  | /usr/local/bundle/gems/sidekiq-scheduler-2.0.19/lib/sidekiq-scheduler/schedule.rb:40:in `schedule='
sidekiq_1  | /gathrly/config/initializers/scheduler.rb:5:in `block (2 levels) in <top (required)>'
sidekiq_1  | /usr/local/bundle/gems/sidekiq-4.2.3/lib/sidekiq/util.rb:54:in `block in fire_event'
sidekiq_1  | /usr/local/bundle/gems/sidekiq-4.2.3/lib/sidekiq/util.rb:52:in `each'
sidekiq_1  | /usr/local/bundle/gems/sidekiq-4.2.3/lib/sidekiq/util.rb:52:in `fire_event'
sidekiq_1  | /usr/local/bundle/gems/sidekiq-4.2.3/lib/sidekiq/cli.rb:79:in `run'
sidekiq_1  | /usr/local/bundle/gems/sidekiq-4.2.3/bin/sidekiq:12:in `<top (required)>'
sidekiq_1  | /usr/local/bundle/bin/sidekiq:17:in `load'
sidekiq_1  | /usr/local/bundle/bin/sidekiq:17:in `<top (required)>'
sidekiq_1  | /usr/local/bundle/gems/bundler-1.14.6/lib/bundler/cli/exec.rb:74:in `load'
sidekiq_1  | /usr/local/bundle/gems/bundler-1.14.6/lib/bundler/cli/exec.rb:74:in `kernel_load'
sidekiq_1  | /usr/local/bundle/gems/bundler-1.14.6/lib/bundler/cli/exec.rb:27:in `run'
sidekiq_1  | /usr/local/bundle/gems/bundler-1.14.6/lib/bundler/cli.rb:335:in `exec'
sidekiq_1  | /usr/local/bundle/gems/bundler-1.14.6/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
sidekiq_1  | /usr/local/bundle/gems/bundler-1.14.6/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
sidekiq_1  | /usr/local/bundle/gems/bundler-1.14.6/lib/bundler/vendor/thor/lib/thor.rb:359:in `dispatch'
sidekiq_1  | /usr/local/bundle/gems/bundler-1.14.6/lib/bundler/cli.rb:20:in `dispatch'
sidekiq_1  | /usr/local/bundle/gems/bundler-1.14.6/lib/bundler/vendor/thor/lib/thor/base.rb:440:in `start'
sidekiq_1  | /usr/local/bundle/gems/bundler-1.14.6/lib/bundler/cli.rb:11:in `start'
sidekiq_1  | /usr/local/bundle/gems/bundler-1.14.6/exe/bundle:32:in `block in <top (required)>'
sidekiq_1  | /usr/local/bundle/gems/bundler-1.14.6/lib/bundler/friendly_errors.rb:121:in `with_friendly_errors'
sidekiq_1  | /usr/local/bundle/gems/bundler-1.14.6/exe/bundle:24:in `<top (required)>'
sidekiq_1  | /usr/local/bundle/bin/bundle:22:in `load'
sidekiq_1  | /usr/local/bundle/bin/bundle:22:in `<main>'

It seems I’m getting a fairly typical nilclass error. However, the way this code is run in production (WITHOUT DOCKER) is fine and sidekiq jobs fire off without any issues. However, sidekiq doesn’t like my app in development mode with docker. I am new to docker so I don’t have a lot of expertise in how it runs. I would like to know how to get sidekiq to run in development mode with docker and be able to fire off jobs.

I have my sidekiq.yml and sidekiq_scheduler.yml file inside my /config folder of my rails app and my sidekiq.rb and scheduler.rb file inside of /config/initializers. Again, the structure of sidekiq runs fine without docker in production mode. Anyone that can point me in the proper direction of how to deal with the issue I’m having would be awesome. SO is kind of silent on the question so far.

Here is my docker-compose.yml file if that might yield any additional info and just ask if you need anything else:

version: '2'
services:
  db:
    image: postgres:9.6.0
  redis:
    image: redis:3.2.4
    command: redis-server
    ports:
      - '6379:6379'
    volumes:
      - '.:/var/lib/redis/data'
  sidekiq:
    build: .
    command: bundle exec sidekiq -C config/sidekiq.yml
    env_file: .env
    links:
      - db
      - redis
  web:
    build: .
    command: bundle exec rails s -p 3000 -b '0.0.0.0'
    env_file: .env
    volumes:
      - .:/my_project
    ports:
      - '3000:3000'
    depends_on:
      - db
      - redis

Could you please try your use case without any host mounts (volumes in the compose file)?

This will help us narrow down the cause of the problem. Also, please feel free to open an issue on the tracker at https://github.com/docker/for-mac/issues if you can provide a full reproduction of the issue (that is, all of the configuration files needed to show the issue). For the issue report, it would be very helpful to try to minimize the number of factors involved in reproducing the issue.

Thanks!

I’ve removed both volume sections from the docker-compose file and rebuilt and then started up my app. I’ve included the full output. It seems to be exactly the same as what it was before.

db_1       | LOG:  database system was shut down at 2017-03-16 18:04:54 UTC
redis_1    | 1:C 16 Mar 18:05:37.425 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
redis_1    |                 _._
redis_1    |            _.-``__ ''-._
redis_1    |       _.-``    `.  `_.  ''-._           Redis 3.2.4 (00000000/0) 64 bit
db_1       | LOG:  MultiXact member wraparound protections are now enabled
redis_1    |   .-`` .-```.  ```\/    _.,_ ''-._
redis_1    |  (    '      ,       .-`  | `,    )     Running in standalone mode
db_1       | LOG:  database system is ready to accept connections
redis_1    |  |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
db_1       | LOG:  autovacuum launcher started
redis_1    |  |    `-._   `._    /     _.-'    |     PID: 1
redis_1    |   `-._    `-._  `-./  _.-'    _.-'
redis_1    |  |`-._`-._    `-.__.-'    _.-'_.-'|
redis_1    |  |    `-._`-._        _.-'_.-'    |           http://redis.io
redis_1    |   `-._    `-._`-.__.-'_.-'    _.-'
redis_1    |  |`-._`-._    `-.__.-'    _.-'_.-'|
redis_1    |  |    `-._`-._        _.-'_.-'    |
redis_1    |   `-._    `-._`-.__.-'_.-'    _.-'
redis_1    |       `-._    `-.__.-'    _.-'
redis_1    |           `-._        _.-'
redis_1    |               `-.__.-'
redis_1    |
redis_1    | 1:M 16 Mar 18:05:37.426 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
redis_1    | 1:M 16 Mar 18:05:37.427 # Server started, Redis version 3.2.4
redis_1    | 1:M 16 Mar 18:05:37.427 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
redis_1    | 1:M 16 Mar 18:05:37.427 * DB loaded from disk: 0.000 seconds
redis_1    | 1:M 16 Mar 18:05:37.427 * The server is now ready to accept connections on port 6379
web_1      | => Booting Puma
web_1      | => Rails 5.0.0.1 application starting in development on http://0.0.0.0:3000
web_1      | => Run `rails server -h` for more startup options
sidekiq_1  | 2017-03-16T18:05:43.377Z 1 TID-go9y1f8d0 INFO: Booting Sidekiq 4.2.3 with redis options {:url=>"redis://redis:6379/"}
web_1      | Puma starting in single mode...
web_1      | * Version 3.6.0 (ruby 2.3.1-p112), codename: Sleepy Sunday Serenity
web_1      | * Min threads: 5, max threads: 5
web_1      | * Environment: development
web_1      | * Listening on tcp://0.0.0.0:3000
web_1      | Use Ctrl-C to stop
sidekiq_1  | 2017-03-16T18:05:43.705Z 1 TID-go9y1f8d0 INFO: Running in ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-linux]
sidekiq_1  | 2017-03-16T18:05:43.705Z 1 TID-go9y1f8d0 INFO: See LICENSE and the LGPL-3.0 for licensing details.
sidekiq_1  | 2017-03-16T18:05:43.705Z 1 TID-go9y1f8d0 INFO: Upgrade to Sidekiq Pro for more features and support: http://sidekiq.org
sidekiq_1  | 2017-03-16T18:05:43.711Z 1 TID-go9y1f8d0 INFO: Loading Schedule
sidekiq_1  | 2017-03-16T18:05:43.712Z 1 TID-go9y1f8d0 INFO: Schedule empty! Set Sidekiq.schedule
sidekiq_1  | 2017-03-16T18:05:43.713Z 1 TID-go9y1f8d0 INFO: Schedules Loaded
sidekiq_1  | 2017-03-16T18:05:43.715Z 1 TID-go9y1f8d0 WARN: {"context":"Exception during Sidekiq lifecycle event.","event":"startup"}
sidekiq_1  | 2017-03-16T18:05:43.715Z 1 TID-go9y1f8d0 WARN: TypeError: can't dup NilClass
sidekiq_1  | 2017-03-16T18:05:43.716Z 1 TID-go9y1f8d0 WARN: /usr/local/bundle/gems/sidekiq-scheduler-2.0.19/lib/sidekiq-scheduler/schedule.rb:126:in `dup'
sidekiq_1  | /usr/local/bundle/gems/sidekiq-scheduler-2.0.19/lib/sidekiq-scheduler/schedule.rb:126:in `block in prepare_schedule'
sidekiq_1  | /usr/local/bundle/gems/sidekiq-scheduler-2.0.19/lib/sidekiq-scheduler/schedule.rb:125:in `each'
sidekiq_1  | /usr/local/bundle/gems/sidekiq-scheduler-2.0.19/lib/sidekiq-scheduler/schedule.rb:125:in `prepare_schedule'
sidekiq_1  | /usr/local/bundle/gems/sidekiq-scheduler-2.0.19/lib/sidekiq-scheduler/schedule.rb:40:in `schedule='
sidekiq_1  | /gathrly/config/initializers/scheduler.rb:5:in `block (2 levels) in <top (required)>'
sidekiq_1  | /usr/local/bundle/gems/sidekiq-4.2.3/lib/sidekiq/util.rb:54:in `block in fire_event'
sidekiq_1  | /usr/local/bundle/gems/sidekiq-4.2.3/lib/sidekiq/util.rb:52:in `each'
sidekiq_1  | /usr/local/bundle/gems/sidekiq-4.2.3/lib/sidekiq/util.rb:52:in `fire_event'
sidekiq_1  | /usr/local/bundle/gems/sidekiq-4.2.3/lib/sidekiq/cli.rb:79:in `run'
sidekiq_1  | /usr/local/bundle/gems/sidekiq-4.2.3/bin/sidekiq:12:in `<top (required)>'
sidekiq_1  | /usr/local/bundle/bin/sidekiq:17:in `load'
sidekiq_1  | /usr/local/bundle/bin/sidekiq:17:in `<top (required)>'
sidekiq_1  | /usr/local/bundle/gems/bundler-1.14.6/lib/bundler/cli/exec.rb:74:in `load'
sidekiq_1  | /usr/local/bundle/gems/bundler-1.14.6/lib/bundler/cli/exec.rb:74:in `kernel_load'
sidekiq_1  | /usr/local/bundle/gems/bundler-1.14.6/lib/bundler/cli/exec.rb:27:in `run'
sidekiq_1  | /usr/local/bundle/gems/bundler-1.14.6/lib/bundler/cli.rb:335:in `exec'
sidekiq_1  | /usr/local/bundle/gems/bundler-1.14.6/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
sidekiq_1  | /usr/local/bundle/gems/bundler-1.14.6/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
sidekiq_1  | /usr/local/bundle/gems/bundler-1.14.6/lib/bundler/vendor/thor/lib/thor.rb:359:in `dispatch'
sidekiq_1  | /usr/local/bundle/gems/bundler-1.14.6/lib/bundler/cli.rb:20:in `dispatch'
sidekiq_1  | /usr/local/bundle/gems/bundler-1.14.6/lib/bundler/vendor/thor/lib/thor/base.rb:440:in `start'
sidekiq_1  | /usr/local/bundle/gems/bundler-1.14.6/lib/bundler/cli.rb:11:in `start'
sidekiq_1  | /usr/local/bundle/gems/bundler-1.14.6/exe/bundle:32:in `block in <top (required)>'
sidekiq_1  | /usr/local/bundle/gems/bundler-1.14.6/lib/bundler/friendly_errors.rb:121:in `with_friendly_errors'
sidekiq_1  | /usr/local/bundle/gems/bundler-1.14.6/exe/bundle:24:in `<top (required)>'
sidekiq_1  | /usr/local/bundle/bin/bundle:22:in `load'
sidekiq_1  | /usr/local/bundle/bin/bundle:22:in `<main>'
sidekiq_1  | 2017-03-16T18:05:43.718Z 1 TID-go9y1f8d0 INFO: Starting processing, hit Ctrl-C to stop