Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't run docker compose in powershell script on Windows agent in Azure Pipeline

My script:

cd $(Build.SourcesDirectory)
docker compose up

I get:

##[error]error during connect: this error may indicate that the docker daemon is not running: Get "http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.24/containers/json?all=1&filters=%7B%22label%22%3A%7B%22com.docker.compose.config-hash%22%3Atrue%2C%22com.docker.compose.project%3Ddmdinference%22%3Atrue%7D%7D": open //./pipe/docker_engine: Access is denied.

I launched docker desktop from my user account. Pipeline is working from system account.

like image 804
Intolighter Avatar asked Nov 16 '25 08:11

Intolighter


1 Answers

From the error message, it indicates that the system account have no access to the path //./pipe/docker_engine to start the docker daemon.

To solve this issue, you can refer to the following two methods:

1.You can grant the permission to the system account which pipeline is using to access the path: //./pipe/docker_engine

PowerShell sample:

$account="<DOMAIN>\<USERNAME>"
$npipe = "\\.\pipe\docker_engine"                                                                                 
$dInfo = New-Object "System.IO.DirectoryInfo" -ArgumentList $npipe                                               
$dSec = $dInfo.GetAccessControl()                                                                                 
$fullControl =[System.Security.AccessControl.FileSystemRights]::FullControl                                       
$allow =[System.Security.AccessControl.AccessControlType]::Allow                                                  
$rule = New-Object "System.Security.AccessControl.FileSystemAccessRule" -ArgumentList $account,$fullControl,$allow
$dSec.AddAccessRule($rule)                                                                                        
$dInfo.SetAccessControl($dSec)

Or you can use the dockeraccesshelper Powershell Module to grant the access.

2.You can change to use the user account to run the Pipeline Agent.

For more detailed steps, you can refer to my ticket.

like image 172
Kevin Lu-MSFT Avatar answered Nov 17 '25 20:11

Kevin Lu-MSFT