I’m not winning in trying to build a .NET application in Debug / Release mode conditionally using an argument (dotnet build’s “-c” parameter). The argument is not substituted by Docker
So I’ve distilled my DockerFile down to:
FROM microsoft/dotnet:2.2-aspnetcore-runtime-nanoserver-1809 AS base
ARG my_var=Debug
ENV my_var=$my_var
#RUN dotnet build myproject.csproj -c $my_var -o /app // dotnet build complains
// about invalid configuration parameter
ENTRYPOINT echo argument is $my_var
, and run
docker build -t testing .
then
docker run -it testing
The output never reflects the argument (Here I’m using the default, ‘Debug’, but passing the --build-arg through during build also does the same thing).
The argument / env is never substituted. The run output is:
argument is $my_var
I’ve tried to remove the ENV-creation and all combinations of inverted commas, ${}, etc. to no avail. What haven’t I grasped??
Docker Version:
Client: Docker Engine - Community
Version: 18.09.2
API version: 1.39
Go version: go1.10.8
Git commit: 6247962
Built: Sun Feb 10 04:12:31 2019
OS/Arch: windows/amd64
Experimental: false