I'm trying to use a Docker image as a build agent in an Azure pipeline. I'm using Azure DevOps Server 2019 and Docker Enterprise Edition.
I get this error when the pipeline runs:
##[section]Starting: Initialize containers
##[command]C:\Program Files\Docker\docker.EXE version --format '{{.Server.APIVersion}}'
error during connect: Get http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.40/version: open //./pipe/docker_engine: Access is denied. In the default daemon configuration on Windows, the docker client must be run elevated to connect. This error may also indicate that the docker daemon is not running.
'
##[error]Exit code 1 returned from process: file name 'C:\Program Files\Docker\docker.EXE', arguments 'version --format '{{.Server.APIVersion}}''.
##[section]Finishing: Initialize containers
I've verified that Docker is installed on the server. I ran the following commands to make sure Docker is running on the server and all ran successfully:
Start-Service Docker
docker network ls
docker version
Here is the pipeline YAML file I'm using:
trigger:
none
resources:
containers:
- container: angulardocker
image: mdailey77/angularbuild:1.0
endpoint: Docker Hub
stages:
- stage: Client
jobs:
- job: BuildTest
pool:
name: Default Windows
container: angulardocker
steps:
- task: Npm@1
displayName: 'Client Build'
inputs:
command: custom
customCommand: run build -- --prod
workingDir: client
- task: CopyFiles@2
displayName: 'Copy Client Build to Staging Directory'
inputs:
contents: '**'
SourceFolder: $(Build.SourcesDirectory)/client/dist
targetFolder: $(Build.ArtifactStagingDirectory)/client
- task: PublishBuildArtifacts@1
displayName: 'Publish Build Artifact - Client'
inputs:
pathToPublish: '$(Build.ArtifactStagingDirectory)/client'
artifactName: 'Client'
The error occurs at the initialization container pipeline step. The Microsoft documentation regarding Docker images as build agents is lacking to say the least. It was no help at all. This post I found had the best example: https://im5tu.io/article/2018/12/building-a-custom-build-agent-image-with-docker-and-azure-devops-pipelines/. I can't figure out the error and stuck at the moment.
UPDATE: After doing more research and @vaibhavnd suggestion, I'm fairly certain the issue is my pipeline build agent doesn't have access to the Docker daemon. True to form, the Microsoft documentation mentions this but doesn't actually show how to do it. How do I configure my build agents so they have access? What would be the steps?
UPDATE 2: I looked into adding a user to the docker-user group, but there is no such group on the server. According to one GitHub post, the docker user group is supposed to be automatically created after installing Docker and doing a restart. I restarted the server and the group still doesn't exist.