Docker: Using Docker as a Remote Interpreter
The following is only valid when Docker integration and Ruby Docker plugins are installed and enabled!
RubyMine integration with Docker allows you to run your applications in the variously configured development environments deployed in Docker containers.
Make sure that the following prerequisites are met:
- Docker is installed, as described on the page Docker Docs. You can install Docker on the various platforms, but here we'll use the mac OS installation.
Before you start working with Docker, make sure that the Docker Integration and Ruby Docker plugins are enabled. The plugins are bundled with RubyMine and activated by default. If the plugins are not activated, enable them on the Plugins page of the Settings / Preferences Dialog as described in Enabling and Disabling Plugins.
Preparing an example
Go to, then point to :
Enter the repository's URL and click Test just in case... Your connection is successful! Next, click Clone to download the project from GitHub. RubyMine asks you whether you want to open the directory - answer Yes.
Then, open the file
routes.rb (Ctrl+Shift+N) and add the following code:
root :to => 'projects#index'
Configuring Docker as a remote interpreter
Now that we've prepared our example, let's define a Docker-based remote interpreter.
To do it, open the Preferences dialog (press Ctrl+Alt+S or click on the main toolbar).
Next, click the Ruby SDK and Gems page. On this page, click + and choose New remote...:
In the dialog box that opens, select the Docker option, from the drop-down lists select the Docker server (if the server is missing, click New...) and image name. If the image is missing, in the Terminal execute the following commands:
docker build .
docker tag <image ID> docker_rails_sqlite
By the way, RubyMine suggests an intention action in the
Gemfile for running the
docker build . command.
Ruby interpreter path should have the default value:
As a result, in the Preferences dialog, Ruby SDK from the Docker container should appear in the list of available SDKs, marked with the 'Remote' prefix. Later, you have to select this new interpreter as the project interpreter, by selecting the corresponding radio-button:
Apply changes and close the dialog.
Running your application in a Docker container
As we have a Rails application, we should choose the environment (here it's Production) and execute the Rake command for migrations (
db:migrate) in the Production environment. Next, select the Rails server for Production environment run/debug configuration and click :
The Run tool window shows the output:
Follow the suggested link, and see:
Debugging your application in a Docker container
Next, let's debug our application. For that, let's put a breakpointto
projects_controller.rb file, to the line
@projects = Projects.all, then click button next to the run/debug configurations selector.
Docker tool window
But is it possible to see all the containers without the Terminal? RubyMine says - yes. You can use the Docker Tool Window as the UI for the Docker command-line client.
If you have configured Docker as a remote interpreter, you will see the Docker tool window button at the bottom side of the main RubyMine window:
Click this button and see that the Docker tool window opens:
Let's look at this tool window more attentively. What do we see here?
- First, we are connected to a Docker daemon:
- Second, if we open the Run tool window, we'll see that the contents of the Console tab of the Run tool window is the same as the contents of the Log tab of the Docker tool window:
- Third, in the Docker tool window the running container log shows the same output as the Debug tool window console:
- And finally, we see the strange names of the containers - they are human-readable and generated by Docker itself.
Let's summarize what has been done with the help of RubyMine:
- We downloaded a Rails project from GitHub and opened it.
- We configured the remote interpreter.
- We ran our Rails project in the Docker container.
- Finally, we launched the Docker tool window and saw all the details visible in the Terminal.