Solving Environment Drift with RubyMine Docker Remote SDKs
Eliminate environment drift by using RubyMine's Docker Remote SDK to run and debug Rails applications inside production-mirroring containers.
15 Dec 2025, 02:07 UTC

The "Works on My Machine" Bottleneck
Runtime failures often occur when the Ruby version, Rails framework, or native gem extensions on a developer's local machine differ from the production environment. This "environment drift" leads to bugs that only appear after deployment. The most effective way to eliminate this is to move the execution environment entirely into a container. RubyMine's Docker remote development allows the IDE to use a container as the project's SDK (Software Development Kit), meaning the code is written locally but executed, tested, and debugged inside a production-mirroring image.
Configuring the Remote SDK
To use this feature, you must have Docker Desktop installed and running on your host. In RubyMine, navigate to Settings (or Preferences on macOS) > Build, Execution, Deployment > Docker to ensure the IDE can communicate with the Docker daemon.
Once connected, you need to define the project's interpreter:
- Open Project Structure (Ctrl+Alt+Shift+S / Cmd+;).
- Under SDKs, click the + button and select Docker.
- Choose your base image (e.g., an official
ruby:3.3image or a custom project image). - Map your local project directory to a path inside the container (e.g.,
/app) to ensure code changes sync in real-time. - Define environment variables, such as
DATABASE_URL, so the IDE can resolve dependencies and connect to services within the container network.
Worked Example: Rails Container Integration
For a Rails 7 application, you first need a Dockerfile that includes the system libraries required for native gem extensions (like pg for PostgreSQL). Create this file in your project root:
FROM ruby:3.3
# Install system dependencies for native extensions
RUN apt-get update && apt-get install -y build-essential libpq-dev
WORKDIR /app
COPY Gemfile Gemfile.lock ./
RUN bundle install
COPY . .
CMD ["rails", "server", "-b", "0.0.0.0"]
After building this image, set it as the Remote SDK in RubyMine. When you run the Rails server via the IDE's run configuration, RubyMine launches the container and maps the host port (e.g., 3000) to the container port. You can then access the app at http://localhost:3000. To verify the execution context, open the RubyMine terminal and run bundle list; the output will reflect the gems installed in the container image, not your local system.
Resource Trade-offs and Constraints
Using a remote SDK introduces specific overheads. Containers consume more host RAM and CPU than a native Ruby process, and there is a slight startup latency when the IDE initializes the container for the first time.
A critical limitation is the requirement for system-level libraries. If your Gemfile includes gems like nokogiri or pg, but your Docker image lacks libxml2-dev or libpq-dev, the bundle install process will fail inside the container even if it works on your macOS or Windows host. Additionally, ensure your port mappings are explicit; if the Rails server binds to 0.0.0.0 inside the container but the host port isn't mapped, you will receive a "Connection Refused" error.
Verifying the Setup
To confirm the environment is correctly isolated, perform these three checks:
- SDK Check: In Project Structure > SDKs, verify the SDK type is listed as "Docker" with the correct image tag.
- Execution Check: Run
bundle exec rails testfrom the RubyMine terminal. Confirm the output shows the tests running against the containerized Ruby version. - Log Check: Open Docker Desktop and inspect the container logs to ensure the Rails boot sequence completed without environment-related errors.
By committing this Dockerfile to version control, you can use the same image for your CI/CD pipeline. This ensures that the environment used for local development in RubyMine is identical to the one used for automated testing and final production deployment.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.