I'm developing an ASP.NET Core application with Visual Studio 2017. I've set up debugging to run the server in a docker container. The container is up and running, but I can't access the database, which is hosted in another docker container.
The database container exposes a port on the host. I need to tell the ASP.NET Core container to map the host's port to an internal port. For this I need to change the docker run command Visual Studio issues to run the container.
Where can I find it so I can change it?
By default, Docker runs on port 80 with ASP.NET Core, but you can override that. In the example below, the Kestrel server that will run in the container is being configured to listen on port 5000. The other environment variable is simply specifying our environment, which is development in this case.
You can add the <DockerfileRunArguments> tag to the <PropertyGroup> section in your *.csproj file and put additional run parameters there.
e.g.
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<DockerfileRunArguments>-p 5000:6000</DockerfileRunArguments>
</PropertyGroup>
</Project>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With