I’m trying to use Azure App Service Containers to host Azure DevOps Pipeline agents. I’ve got everything working in the sense that my agent runs great locally using Docker Desktop, but when I publish the image to the App Service, the startup command is never executed. I’m forced to get a console in the container and manually run the powershell script, which then works as expected.
Here is my docker file:
FROM mcr.microsoft.com/windows/servercore:ltsc2019
RUN powershell Install-PackageProvider -Name NuGet -Force
RUN powershell Install-Module PowershellGet -Force
RUN powershell Install-Module -Name Az -Repository PSGallery -Force
RUN powershell Install-Module -Name Az.Tools.Migration -Repository PSGallery -Force
RUN powershell Enable-AzureRMAlias
WORKDIR /azp
COPY start.ps1 .
CMD powershell "c:azpstart.ps1"
The deployment center logs show no errors. It’s as if the CMD is never run.
3
Answers
please replace powershell CMD line as below –
also its always good to use the full path for the exe if its not exist in PATH.
also use workdir as below –
I did not try building your docker image, but you should investigated on how
ENTRYPOINT
is defined, and so how it interacts withCMD
.Look at the Official Guide.
According to docker documentation, if you want a command to be always executed you must pass it in ENTRYPOINT and not in CMD.
When you pass your command in CMD, it can be overridden by an argument when the container is executed.
So I don’t know how you run your container but I advise you to try to pass your script in ENTRYPOINT.
Something like that: