用于 ASP.NET Core 和 Visual Studio 2017 的 docker run 命令 [英] docker run command for ASP.NET Core and Visual Studio 2017

查看:15
本文介绍了用于 ASP.NET Core 和 Visual Studio 2017 的 docker run 命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Visual Studio 2017 开发 ASP.NET Core 应用程序.我已设置调试以在 docker 容器中运行服务器.容器已启动并正在运行,但我无法访问托管在另一个 docker 容器中的数据库.

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.

数据库容器在主机上公开一个端口.我需要告诉 ASP.NET Core 容器将主机的端口映射到内部端口.为此,我需要更改 Visual Studio 发出的 docker run 命令以运行容器.

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?

推荐答案

你可以添加 <DockerfileRunArguments>标记到 <PropertyGroup>*.csproj 文件中的部分并在其中放置其他运行参数.

You can add the <DockerfileRunArguments> tag to the <PropertyGroup> section in your *.csproj file and put additional run parameters there.

例如

<Project Sdk="Microsoft.NET.Sdk.Web">
  <PropertyGroup>
    <DockerfileRunArguments>-p 5000:6000</DockerfileRunArguments>
  </PropertyGroup>
</Project>

这篇关于用于 ASP.NET Core 和 Visual Studio 2017 的 docker run 命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆