13

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?

1
  • Alternatively you can create a new profile under Debug and set the executable as docker.exe and pass along the application arguments and environment variables as required . Within the application arguments you can add the additional port mapping option mapping the host port to the internal port for the DB container . I looked up the full command that Visual Studio was executing from the output window and just copied it to the application arguments , it does starts the new container when executed. Commented Jan 13, 2019 at 10:42

2 Answers 2

23

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>
Sign up to request clarification or add additional context in comments.

Comments

4

You cannot change the command , however you may create a new Debug Profile and make modifications to the Application Arguments...something like this enter image description here

1 Comment

That's very annoying. Why would Microsoft limit that?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.