Reputation: 3253
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:\azp\start.ps1"
The deployment center logs show no errors. It's as if the CMD is never run.
Upvotes: 11
Views: 1237
Reputation: 447
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.
CMD will be overridden when running the container with alternative arguments.
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:
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 c:\azp
COPY start.ps1 .
ENTRYPOINT ["powershell.exe", "c:\\azp\\start.ps1"]
Upvotes: 0
Reputation: 11040
I did not try building your docker image, but you should investigated on how ENTRYPOINT
is defined, and so how it interacts with CMD
.
Look at the Official Guide.
Upvotes: 0
Reputation: 46
please replace powershell CMD line as below -
CMD ["powershell.exe", "-File", "c:\azp\start.ps1"]
also its always good to use the full path for the exe if its not exist in PATH.
also use workdir as below -
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 c:\azp
COPY start.ps1 .
CMD ["powershell.exe", "-File", "c:\azp\start.ps1"]
Upvotes: 1