Expose a port in Docker container Through the IDE.

Answered

Hi,

 

I'm running my app for debugging in a container using the the docker plugin for intelliJ. I'm using IntelliJ Ultimate 2017.2.5.

Currently, in order to get my debugger to connect to the container I need to modify my docker file and explicitly expose my debug port in the container:

EXPOSE 5005

Obviously this is not ideal. I would like to be able to expose a port through the IntelliJ IDE. I've played around with the container_settings.json which appears to be run by the IDE at container deployment time. 

However, I'm unable to connect to to the debugger port with the remote debugger. When I expose the port explicitly in the docker file again the debugger connects without a problem.

 

Any assistance would be greatly appreciated.

 

 

 

 

0
3 comments
Official comment

I can't reproduce the issue. 

I have just verified that within a context of my previous answer in this youtrack, the following JSON option exposes the port 3555 in addition to the ports exposed in the Dockerfile by EXPOSE instruction. 

  "ExposedPorts" : {  "3555/tcp" : { } },

This is structurally identical to what you have in your JSON file, so I can confirm that your JSON is expected to work and the similar case actually works for me. You may try to replace `"HostIp"="127.0.0.1"` -> `"HostIp"=""` in the "PortBindings" block but I doubt it will help. 

Please note that new docker plugin for IDEA 2017.3 public preview has reworked run configuration and now accepts the most of Docker CLI options directly. And for this new version I have just verified that adding `--expose 3555 -p 5333:3555` into the new "Command line options" field exposes the port 3555 (which was not originally exposed by the Dockerfile) and bounds it to the local port 5333. 

If this does not help, please open a new youtrack for Docker subsystem and attach

  • the whole .idea folder of your project,
  • JSON file for IDEA 172
  • and if possible your Dockerfile for me to reproduce

 

 

Related request: https://youtrack.jetbrains.com/issue/IDEA-149314.

Responsible developer will comment with more details.

0
Avatar
Permanently deleted user

So,

 

Using the docker plugin for IDEA 2017.3 public preview  has resolved this issue. Removing Host IP did not work, as predicted.

I know this is a preview but I'm not working on production changes on the project which requires this functionality at the moment.

Thanks.

 

0

Please sign in to leave a comment.