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?.