❔ Get Console App args inside Docker container with Docker-compose
Hi,
I have trouble with a .NET6 Console App and Docker with the use of args.
If I launch the Console App without Docker in VS22 everything is okay, my args are retrieved, but when I use with Docker container inside a Docker-compose nothing happen...
I tried to edit the Dockerfile to hardcode the value of the args, use the "command" part of docker-compose but nothing is working.
Someone have a solution ? I would like to not use env variable to handle args.
Thank you,
Tom.
24 Replies
show how u provide the args and other relevant code.
show your dockerfile
Sorry,
When running locally I used these launchProfiles :
Both profiles are working well.
But when I try to use the Docker inside à Docker-compose I dont success to retrieve args to my console app inside container.
I tried inside Docker-compose :
I tried inside Dockerfile :
Can you show the full dockerfile please?
do you have an
ENTRYPOINT
in your dockerfile?It's the default Dockerfile generated by visual studio
Yes
just show it, please.
the entire file
okay i'm on it
The weird things is that with launchProfiles and the Docker container launched alone the args are working well with the instruction :
But I cant figure out how to make the equivalent instruction for my docker-compose file
so what exactly are you trying to do
set command like args via the dockerfile? set it via the compose file?
i am trying to pass "args1", "args2", "args3" while running my console app from a docker-compose via the compose file
i would like to not rebuild my dockerfile each time I change the args value, just recreate the container with the right args
maybe I am wrong, but the commandLineArgs seems to create the container with passing args ex :
and I dont need to rebuild my dockerfile each time ?
commandLineArgs
, in what file?launchSettings.json
it's basically a launch option for the project
well yes, but that file is part of your image.
container
so i am wrong and even running the Docker container alone, I need to rebuild the Dockerfile If I change the value inside my launchSettings.json ?
You'd need to rebuild the docker image if you change the launchSettings file, yes
so I don't recommend setting it that way
Do you have a better way to advise me ?
hm, this is very weird... my initial thought was to use
CMD
in the dockerfile and command
in compose to override it, but I can't even get it to work with ENTRYPOINT
ENTRYPOINT ["dotnet", "EchoArgs.dll", "asd", "asd"]
doesnt seem to work, while running that exact command myself works fineit seems like vs22 is doing more thing than we thought
GitHub
Please allow extra command line parameters to be passed to docker-c...
It would be great to allow extra command line parameters
I'm not using dockertool thou, and Im very confused as to why this doesnt work
When I try to use this in my Docker-compose :
According to ms doc https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-run#options
I have these logs in my container :
very weird....
dotnet run command - .NET CLI
The dotnet run command provides a convenient option to run your application from the source code.
dotnet run
is not invoked for your app thou
just to be clear
it seems to ignore whatever is after the dll in the entrypoint, and the cmd is not applied either
okay, its related to how Rider runs it, and possibly dockertool
if I build that same dockerfile myself using the cli, it works
that... infuriates me, but at least means I'm not going insane
so, build the image yourself and it should work just fine
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.