enable remote debugging in docker


I try to implement remote debugging like explained here:


I have a jruby 9.1 rails application running in docker.

In my Gemfile I have under the development section -->

gem  'debase', '~>0.2.2.beta10', require: false

However, I get an error on "docker build"


Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /usr/local/bundle/gems/debase-0.2.2.beta10/ext
/opt/jruby/bin/jruby -r ./siteconf20170609-7-1ef9cbf.rb extconf.rb
checking for vm_core.h... RuntimeError: The compiler failed to generate an
executable file.
You have to install development tools first.


I have development tools installed in docker ! -->

fetch http://dl-cdn.alpinelinux.org/alpine/v3.5/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.5/community/x86_64/APKINDEX.tar.gz
(1/51) Installing fakeroot (1.21-r1)
(2/51) Installing sudo (1.8.19_p1-r0)
(3/51) Installing libcap (2.25-r1)
(4/51) Installing pax-utils (1.1.6-r0)
(5/51) Installing libressl (2.4.4-r0)
(6/51) Installing libattr (2.4.47-r4)
(7/51) Installing attr (2.4.47-r4)
(8/51) Installing tar (1.29-r1)
(9/51) Installing pkgconf (1.0.2-r0)
(10/51) Installing patch (2.7.5-r1)
(11/51) Installing libssh2 (1.7.0-r2)
(12/51) Installing libcurl (7.52.1-r3)
(13/51) Installing curl (7.52.1-r3)
(14/51) Installing abuild (2.29.0-r2)
Executing abuild-2.29.0-r2.pre-install
(15/51) Installing binutils-libs (2.27-r1)
(16/51) Installing binutils (2.27-r1)
(17/51) Installing gmp (6.1.1-r0)
(18/51) Installing isl (0.17.1-r0)
(19/51) Installing libgomp (6.2.1-r1)
(20/51) Installing libatomic (6.2.1-r1)
(21/51) Installing mpfr3 (3.1.5-r0)
(22/51) Installing mpc1 (1.0.3-r0)
(23/51) Installing gcc (6.2.1-r1)
(24/51) Installing make (4.2.1-r0)
(25/51) Installing musl-dev (1.1.15-r6)
(26/51) Installing libc-dev (0.7-r1)
(27/51) Installing fortify-headers (0.8-r0)
(28/51) Installing g++ (6.2.1-r1)
(29/51) Installing build-base (0.4-r1)
(30/51) Installing expat (2.2.0-r0)
(31/51) Installing pcre (8.39-r0)
(32/51) Installing git (2.11.2-r0)
(33/51) Installing xz-libs (5.2.2-r1)
(34/51) Installing lzo (2.09-r1)
(35/51) Installing squashfs-tools (4.3-r3)
(36/51) Installing libburn (1.4.6-r0)
(37/51) Installing libedit (20150325.3.1-r3)
(38/51) Installing libacl (2.2.52-r2)
(39/51) Installing libisofs (1.4.6-r0)
(40/51) Installing libisoburn (1.4.6-r0)
(41/51) Installing xorriso (1.4.6-r0)
(42/51) Installing acct (6.6.2-r0)
(43/51) Installing lddtree (1.25-r2)
(44/51) Installing libuuid (2.28.2-r1)
(45/51) Installing libblkid (2.28.2-r1)
(46/51) Installing device-mapper-libs (2.02.168-r3)
(47/51) Installing cryptsetup-libs (1.7.2-r1)

(48/51) Installing kmod (23-r1)
(49/51) Installing mkinitfs (3.0.9-r1)


RUN apk add --update alpine-sdk

from my Dockerfile.


My mkmf.log file looks:

" -o conftest -I/include/universal-java1.8 -I/opt/jruby/lib/ruby/include/ruby/backward -I/opt/jruby/lib/ruby/include -I.     -fPIC  -fno-omit-frame-pointer -fno-strict-aliasing  -fexceptions  conftest.c  -L. -L/opt/jruby/lib    -m64      "
checked program was:
/* begin */
1: #include "ruby.h"
3: #include <ruby.h>
4: int main(int argc, char **argv)
5: {
6:   return 0;
7: }
/* end */

which looks strange to me because I would expect starting this line with "gcc -o ...". And gcc is installed.

Any advise?







Comment actions Permalink

Hello Thomas, 

in case you're using jruby debug gems are ruby-debug-ide and ruby-debug-base so please check how it goes with them. 

Comment actions Permalink

Hello Olga,

thank you. I'm now close to debugging ;-) I think.

I followed your advise and the build failure disappeared.

My Gemfile looks now like:

group :development, :test do
gem 'ruby-debug'
gem 'ruby-debug-base'
gem 'ruby-debug-ide'

My first problem was that I still got a error at runtime when I started the rails application complaining that rdebug-ide needs some other gems not installed.

So I expanded my Gemfile until the rails-app started successful in the container.

The lines before

  gem 'ruby-debug-base'
gem 'ruby-debug-ide'

are now (inside 'group :development, :test do'):
gem  'i18n', '0.8.1'       # needed by von rdebug-ide 
gem 'minitest', '5.10.1' # needed by von rdebug-ide
gem 'rack', '1.6.5' # needed by von rdebug-ide
gem 'mail', '2.6.4' # needed by von rdebug-ide
gem 'rack-protection', '1.5.3' # needed by von rdebug-ide
gem 'rainbow', '2.2.1' # needed by von rdebug-ide
gem 'rspec-support', '3.5.0' # needed by von rdebug-ide
gem 'sass', '3.4.23' # needed by von rdebug-ide
gem 'ruby-debug-base'
gem 'ruby-debug-ide'

This was a really timeconsuming task. It first failed with a missing i18n, then with a missing minitest ...
Why was it not automatically resolved?

In my Dockerfile I had before debugging:

CMD puma -e $RAILS_ENV

Now with debugging I do:

CMD bundle exec rdebug-ide --host --port 1234 --dispatcher-port 26162 -- /usr/local/bundle/gems/puma-3.8.2-java/bin/puma -e $RAILS_ENV


This are the first two lines from the docker-railscontainer-logfile:

eb_1         | /usr/local/bundle/gems/ruby-debug-base-0.10.6-java/lib/ruby-debug-base.rb:196: warning: tracing (e.g. set_trace_func) will not capture all events without --debug flag
web_1         | Fast Debugger (ruby-debug-ide 0.6.0, ruby-debug-base 0.10.6, file filtering is supported) listens on


Now the real problem:
I can attach from rubymine to the docker process. In the Rubymine debug-variables window I see an info "Connected"
with a blue/white exclamation mark in front.

BUT when I set a breakpoint in the code the execution does not stop when I come to this code line!

Comment actions Permalink

Hello Thomas,

sorry for the delay. There are some parameters that need to be passed to jruby. That probably might be done via JRUBY_OPTS (https://stackoverflow.com/questions/8283300/how-do-i-use-jruby-opts-with-rvm). You need to pass the following:

-J-Djruby.objectspace.enabled=true -J-Djruby.compile.mode=OFF -J-Djruby.debug.fullTrace=true


Please sign in to leave a comment.