2

i run dockerfile

#servercore its mine tag
FROM  servercore 
COPY ./prog./work/prog
WORKDIR /work
CMD ["cmd.exe", "/c", "start /b C:\\work\\prog\\prog.exe"]

then inside of container i type tasklist and see tasklist in this case my program doesn`t work

Also i tried to run exe inside windows servercore with terminal tasklist and my program is fully working, which can be seen in memory in the task manager

How can і run exe by dockerfile ?

StasKE
  • 43
  • 5
  • define your executable as `ENTRYPOINT` – derpirscher Mar 30 '23 at 12:47
  • i replace CMD to ENTRYPOINT but i have same result like on first picture (10 000 k) – StasKE Mar 30 '23 at 13:06
  • So your program is indeed running on startup, isn't it? If it doesn't function correctly on a freshly started system, its probably a problem of your application and not of docker. Does it have any dependencies on other services/resources that need to be initialized first? – derpirscher Mar 30 '23 at 13:21
  • my program dont have any dependencies on other services/resources that need to be initialized first. Also i show second srceenshot, if i run exe inside servercore in terminal program.exe all is good, program work – StasKE Mar 30 '23 at 13:31
  • but my task is to make it work correctly when starting the docker container without further intervention – StasKE Mar 30 '23 at 14:04
  • 1
    Well, then you have to find out, why your task doesn't work as expected when started immediately after start. The entrypoint is just calling the provided executable. – derpirscher Mar 30 '23 at 14:09

1 Answers1

2

It might have happened because when you are trying to start your app.exe from different path then your app. It might throw some exception because app does not see all dependencies/resources etc. You should change your workdir from WORKDIR /work to WORKDIR /work/prog and in CMD ./prog.exe.

Scroll
  • 158
  • 2
  • 11