admin管理员组

文章数量:1315294

I want to utilize the VSCode launch configuration for Python debugpy against a docker container process that exposes a dynamic port. The reason it exposes is a dynamic port is because we have multiple similar code bases that can run concurrently on a dev system and we want to avoid port conflict. The problem is I don't know how programmatically I can feed in a random port to this VSCode launch configuration process. Any advice here?

One strategy I was thinking about would be to generate the entire launch config as a hook after I spin up the service.

I haven't tried anything specific beyond looking through the documentation for a possible solution so far.

I want to utilize the VSCode launch configuration for Python debugpy against a docker container process that exposes a dynamic port. The reason it exposes is a dynamic port is because we have multiple similar code bases that can run concurrently on a dev system and we want to avoid port conflict. The problem is I don't know how programmatically I can feed in a random port to this VSCode launch configuration process. Any advice here?

One strategy I was thinking about would be to generate the entire launch config as a hook after I spin up the service.

I haven't tried anything specific beyond looking through the documentation for a possible solution so far.

Share Improve this question asked Jan 31 at 6:05 user1985413user1985413 1 4
  • where is the random port number known. If you write it to a file you can use the extension I made Command Variable, there are different input formats – rioV8 Commented Jan 31 at 6:08
  • it's known after a docker process launches and maps it, i suspect i'll have to do my own extension to get it from docker explicitly? thats a dope extension though you recommended, gotta keep my eye on that use case – user1985413 Commented Feb 11 at 0:31
  • in the script that launches the docker image extract the port number and save it to a file – rioV8 Commented Feb 11 at 23:09
  • Thanks @rioV8 you solved my problem friend! – user1985413 Commented Mar 4 at 0:11
Add a comment  | 

1 Answer 1

Reset to default 0

The short answer is no you cannot do this natively in VSCode unless you leverage an extension.

本文标签: pythonIn launch configscan we feed in dynamic portsStack Overflow