Debugging a Ruby Application in a Docker Container using Visual Studio Code
Ever since DockerCon 2016 in Seattle, I was quite impressed with what I saw with Debugging a ES6 Node.js application in a Docker container using Visual Studio Code from Alexander Zeitler. However I wanted to do this for Ruby.
To start you will need:
- Visual Studio Code <- yes, this runs awesome on your Mac, Windows, or Linux machine.
- Ruby Plugin for Visual Studio Code
- Docker I personally have tested this with Docker for Mac 1.12.3 Stable.
Get up and running quick:
Start by cloning the repository and opening Visual Studio Code
Build the docker container and run it
At this point you should see something similar to:
It will wait here until you Navigate the to Debug View in Visual Studio Code and click the Play button on “Attach to Docker”. After it attaches
then you should see:
From here set a breakpoint in the code in myapp.rb. Then navigate to http://0.0.0.0:4567
You should now hit the breakpoint and be able to step over or step into or play.