Docker Community Forums

Share and learn in the Docker community.

Set network flags when running Docker container from Visual Studio

Hello

I’m new here, sorry if I posted this in the wrong spot.

I recently created my first Docker containtered project in Visual Studio. But I want to set the network flag to host because I want my project to connect to my Mysql server which is running on my host machine.

How do I do this?

Visual Studio generates a dockerfile with this content:

FROM mcr.microsoft.com/dotnet/core/aspnet:2.1-stretch-slim AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/core/sdk:2.1-stretch AS build
WORKDIR /src
COPY [“PaymentSystem/PaymentSystem.csproj”, “PaymentSystem/”]
RUN dotnet restore “PaymentSystem/PaymentSystem.csproj”
COPY . .
WORKDIR “/src/PaymentSystem”
RUN dotnet build “PaymentSystem.csproj” -c Release -o /app

FROM build AS publish
RUN dotnet publish “PaymentSystem.csproj” -c Release -o /app

FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT [“dotnet”, “PaymentSystem.dll”]

Should I put it somewhere in here?

Thanks for any help!