JetBrains Rider 2019.2 Help

Node.js with Docker

You can quickly bootstrap your Node.js application with Docker, JetBrains Rider will take care of the initial configuration by automatically creating a new Dockerfile, keeping your source code up-to-date and installing npm dependencies in the container. Configuring a Node.js environment running in a Docker container as a Node.js remote interpreter lets you run, debug, and profile your Node.js application from JetBrains Rider.

JetBrains Rider supports debugging of Node.js applications in Docker containers through run/debug configurations of the type Node.js.

You can find some examples at Quick Tour of WebStorm and Docker.

Before you start

  1. Download, install, and configure Docker as described in Docker

  2. Install the NodeJS, NodeJS Remote Interpreter, and Docker Integration repository plugins on the Plugins page as described in Managing plugins.

Create a Node.js run/debug configuration

  1. From the main menu, choose Run | Edit Configuration, then in the Edit Configurations dialog, click the Add button on the toolbar and select Node.js from the list. The Run/Debug Configuration: Node.js dialog opens.

  2. In the JavaScript File field, specify the path to the main file of the application that starts it (for example, bin/www for Node.js Express applications).

  3. If necessary, specify some optional settings as described in Running and debugging Node.js applications.

Specify a Node.js interpreter

Select one of the configured Node.js interpreters of the type Remote Interpreter - Docker from the Node interpreter list or configure a new one.

  1. In the Run/Debug Configuration: Node.js dialog, click the Browse button next to the Node interpreter field.

  2. In the Node.js Interpreters dialog that opens with a list of all the currently configured interpreters, click the Add button on the toolbar. In the dialog that opens, choose Add Remote from the context menu.

  3. In the Configure Node.js Remote Interpreter dialog that opens, select the Docker option.

    1. In the Server field, specify the Docker configuration to use, see Configure the Docker daemon connection settings for details. Select a configuration from the list or click the Browse button and create a new configuration on the Docker page that opens.

    2. In the Image name field, specify the base Docker image to use. Choose one of the previously downloaded or your custom images from the list or type the image name manually, for example, node:argon or mhart/alpine-node. When you later launch the run configuration, Docker will search for the specified image on your machine. If the search fails, the image will be downloaded from the image repository specified on the Docker Registry page.

    3. The Node.js interpreter path field shows the location of the default Node.js interpreter from the specified image.

    4. When you click OK, JetBrains Rider closes the Configure Node.js Remote Interpreter dialog and brings you to the Node.js Interpreters dialog where the new interpreter configuration is added to the list. Click OK to return to the run configuration.

Specify the Docker container settings

  • Click the Browse button next to the Edit Docker Container Settings field and specify the settings in the Edit Docker Container Settings dialog that opens.

  • Alternatively, select the Auto configure checkbox to do it automatically. Learn more about the Auto configure mode at Quick Tour of WebStorm and Docker: What Happens On Each Run.

Even with automatic configuration, you still need to bind the port on which your application is running with the port of the container. Those exposed ports are available on the Docker host’s IP address (by default Such binding is required when you debug the client side of a Node.js Express application. In this case, you need to open the browser from your computer and access the application at the container host through the port specified in the application.

Configure port bindings

  1. Click the Browse button in the Docker Container Settings field and expand the Port bindings area in the Edit Docker Container Settings dialog that opens.

  2. Click the Add button and in the Port bindings dialog that opens, map the ports as follows:

    • In the Container port field, type the port specified in your application.

    • In the Host port field, type the port through which you want to open the application in the browser from your computer.

    • In the Host IP field, type the IP address of the Docker's host, the default IP is The host is specified in the API URL field on the Docker page of the Settings/Preferences.

    • Click OK to return to the Edit Docker Container Settings dialog where the new port mapping is added to the list.

  3. Click OK to return to the Run/Debug Configuration: Node.js dialog.

Start debugging

  1. Set the breakpoints in the Node.js code as necessary.

  2. Select the newly created Node.js configuration from the Select run/debug configuration list on the toolbar and click the Debug button next to it.

  3. Proceed as during a local debugging session, as described above.

Using a remote Node.js interpreter in a Docker container with a Docker Compose definition

With Docker Compose, you can run a Node.js server and your application code as separate services. Each service can be scaled by adding more containers if necessary. This enables you to perform efficient development and testing in a dynamic environment that is similar to production one.

Configuring mappings

When you debug an application with a remote Node.js interpreter, the debugger tells JetBrains Rider the name of the currently processed file and the number of the line to be processed. JetBrains Rider opens the local copy of this file and indicates the line with the provided number. This behaviour is enabled by specifying correspondence between files and folders on the server and their local copies. This correspondence is called mapping, it is set in the debug configuration.

To configure mappings

  1. From the main menu, choose Run | Edit Configurations. In the Edit Configuration dialog that opens, click the Add New Configuration button on the toolbar and choose Node.js from the context menu.

  2. In the Run/Debug Configuration: Node.js dialog that opens, choose the required remote interpreter from the Node interpreter list.

  3. Click the Browse button next to the Path Mappings field.

  4. The Edit Project Path Mappings Dialog that opens, shows the path mappings retrieved from the deployment configuration or Vagrantfile. These mappings are read-only.

    • To add a custom mapping, click the Add button and specify the path in the project and the corresponding path on the remote runtime environment in the Local Path and Remote Path fields respectively. Type the paths manually or click the Browse button and select the relevant files or folders in the dialog that opens.

    • To remove a custom mapping, select it in the list and click the Remove button.

Last modified: 29 November 2019