1

I have a YAML pipeline in Azure DevOps that has a docker run command. After the artifact is created by the build stage I use the DockerInstaller@0 task to install Docker.

When I ran the docker run command I get the error Cannot connect to the Docker daemon at unix:///var/run/docker.sock.

- task: DockerInstaller@0
  displayName: 'Install Docker 17.09.0-ce'

- bash: |
    chmod -R 777 ./
    docker run --rm -v $(pwd):/zap/wrk/:rw -t owasp/zap2docker-stable zap-baseline.py -t https://app.azurewebsites.net -g gen.conf -x zap-report.xml -r zap-report.html -J zap-report-fe.json
    true
  displayName: 'Run OWASP Zap'

What's strange is that these commands work just fine whenever I use the Microsoft-hosted agent (using ubuntu-latest). The error happens whenever I use our self-hosted agent (using Ubuntu 18.04). If anyone can provide guidance that would be great!

Logs

DockerInstaller@0

Verifying docker installation...
##[debug]which 'docker'
##[debug]found: '/home/linux_admin/myagent/_work/_tool/docker-stable/17.9.0-ce/x64/docker'
...
##[debug]arguments:
##[debug]   --version
/home/linux_admin/myagent/_work/_tool/docker-stable/17.9.0-ce/x64/docker --version
Docker version 17.09.0-ce, build afdb6d4

Run OWASP ZAP

========================== Starting Command Output ===========================
##[debug]which '/bin/bash'
##[debug]found: '/bin/bash'
##[debug]/bin/bash arg: /home/linux_admin/myagent/_work/_temp/19ec79e8-7fff-417f-b64a-56b66c89074c.sh
##[debug]exec tool: /bin/bash
##[debug]arguments:
##[debug]   /home/linux_admin/myagent/_work/_temp/19ec79e8-7fff-417f-b64a-56b66c89074c.sh
/bin/bash /home/linux_admin/myagent/_work/_temp/19ec79e8-7fff-417f-b64a-56b66c89074c.sh
docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.

1 Answer 1

2

I venture to guess that the task DockerInstaller@0 doesn't work properly. In case of Microsoft-hosted agent, Docker client and server are already pre-installed. Thus, you don't need to run that task.

You can manually install and configure Docker on your build agent server. Make sure that the user which build agent service run as is a member of docker group.

Sign up to request clarification or add additional context in comments.

6 Comments

I updated the question with the logs that I got from the build. It seemed to show that the DockerInstall task was successful, but my interpretation could be wrong.
According its docs - DockerInstaller@0 installs only docker CLI(client). It doesn't install docker demon.
Now it makes sense. We have installed the Docker engine in the build agent and we are now able to execute docker run, although we received a permission denied error. Do you know how we can identify the user that the pipelines are using in the build agent so that we can add it in the docker group?
You can make a pipeline to run "whoami" command and check the output.
Did you resolve this? I added whoami and I get "agent". That user is in the docker group but still not working :(
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.