Docker Community Forums

Share and learn in the Docker community.

.Net Core Console app with custom parameter in Docker

Hi
i have created sample calculator .net core console application to sum two integers.

image

so in DoSum method, i have pass static parameter,
but when i run in docker i want to pass parameter outside of the application.

so how I can achieve this?

my docker file is:

FROM mcr.microsoft.com/dotnet/core/runtime AS base

WORKDIR /app

FROM mcr.microsoft.com/dotnet/core/sdk AS build

WORKDIR /src

COPY [“ECSConsole.csproj”, “./”]

RUN dotnet restore “./ECSConsole.csproj”

COPY . .

WORKDIR “/src/.”

RUN dotnet build “ECSConsole.csproj” -c Release -o /app/build

FROM build AS publish

RUN dotnet publish “ECSConsole.csproj” -c Release -o /app/publish

FROM base AS final

WORKDIR /app

COPY --from=publish /app/publish .

ENTRYPOINT [“dotnet”, “ECSConsole.dll”]

my docker compose file is

version: ‘3.4’

services:

ecsconsole:

image: ecsconsole

build:

  context: .

  dockerfile: Dockerfile