Docker: Using Docker as a Remote Interpreter
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 plugin is enabled. The plugin is bundled with RubyMine and is activated by default. If the plugin is not activated, enable it on the Plugins page of the Settings / Preferences Dialog as described in Enabling and Disabling Plugins.
Before you start working with Docker, make sure that the Ruby Docker plugin is enabled. The plugin is bundled with RubyMine and is activated by default. If the plugin is not activated, enable it on the Plugins page of the Settings / Preferences Dialog as described in Enabling and Disabling Plugins.
Preparing an example
Download this project from GitHub and open it in RubyMine ().
Then, open the file
route.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:
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 successfully 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:
- 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.