Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set the ServicePort in launchsettings.json for docker

So recently docker-integration in VS2017 has removed the docker project and simply works from launchsettings.json and a Dockerfile.

In my launchsettings.json I have the following:

"Docker": {
      "commandName": "Docker",
      "launchBrowser": true,
      "launchUrl": "{Scheme}://localhost:{ServicePort}/swagger"
    }

Whenever I debug the application a random port is assigned.

If I include a valid sslPort in the iisExpress settings it takes the correct http and https ports from there, however my application is not currently using https so I'd rather not bind an unused port.


The below iisExpress settings seem to influence the docker settings. While below gives me what I want (a consistent binding from 81:80, host:container) I would prefer that port 444 was not also bound, or that the settings within another profile influence a different profile.

"iisExpress": {
      "applicationUrl": "http://localhost:81/",
      "sslPort": 444 (takes a random port if set to 0)
    }

Any ideas? I would just like to be able to set the ServicePort / default port to a known value.

like image 562
Questioning Avatar asked Oct 16 '18 14:10

Questioning


People also ask

Is launchSettings JSON used in Docker?

In launchSettings. json, the settings in the Docker section are related to how Visual Studio handles containerized apps. These command-line arguments for starting your app are used when launching your project in the container. Additional arguments to pass to the docker run command.

How do I edit JSON launchSettings?

You can directly edit the launchSettings. json file in Visual Studio for Mac, or you can use project options to edit it. To get to the project options, right-click your project and select Options. Select Run > Configurations > Default.

Should you commit launchSettings JSON?

This settings will be useful if shared among project members, so it should be commited to the repo.


1 Answers

The Docker section in launchsettings.json supports now httpPort and sslPort settings:

"Docker": {
      ... 
    "httpPort": 8080
}
like image 149
Enriko Riba Avatar answered Sep 17 '22 17:09

Enriko Riba