0
votes

I created ACS instance and registered it as a VSTS Agent. I used image lenisha/vsts-agent-infrastructure to use terraform. Anyway I want to build docker images, but using Agents from ACS I get error: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?. So question is if there is a way to get to docker daemon? I wasn't able to find info about how to mount docker.sock in ACS (-v /var/run/docker.sock:/var/run/docker.sock).

1

1 Answers

2
votes

Just refer to this blog on : Using the Visual Studio Team Services Agent Docker Images

Agent that supports using Containers to build source Finally, we come to the part you are most interested in. How do we actually set up one of these agents and avoid the above errors?

There is an environment variable called VSTS_WORK that specifies where the work should be done by the agent. We can change the location of the directory and volume mount it so that when the docker container runs on the host it will have access to the files.

To create an agent that is capable of using docker in this way:

docker run -e VSTS_ACCOUNT=<youraccountname>  \
  -e VSTS_TOKEN=<your-account-Private-access-token> \
  -e VSTS_WORK=/var/vsts -v /var/run/docker.sock:/var/run/docker.sock \
  -v /var/vsts:/var/vsts -d \ microsoft/vsts-agent:ubuntu-16.04-docker-17.03.0-ce-standard

The important command here is -e VSTS_WORK=/var/vsts which tells the agent to do all the work in the /var/vsts folder. Then volume mounting the folder with -v /var/vsts:/var/vsts enables you to run docker containers inside the VSTS agent and still see all the files.


UPDATE:

Based on my research seems cannot find a way to mount /var/run/docker.sock from host machine inside ACS Container, such as the issue mentioned in this thread : Mounting volume in Azure-Container-Service not working for traefik.toml and /var/run/docker.sock