Azure 容器服务容器作为 VSTS 代理构建 docker 个图像

Azure Container Service Container as a VSTS Agent to build docker images

我创建了 ACS 实例并将其注册为 VSTS 代理。我使用 image lenisha/vsts-agent-infrastructure 来使用 terraform。无论如何,我想构建 docker 个图像,但是使用来自 ACS 的代理我得到错误:Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?。所以问题是是否有办法到达 docker 守护进程?我找不到有关如何在 ACS (-v /var/run/docker.sock:/var/run/docker.sock) 中挂载 docker.sock 的信息。

请参阅此博客: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.


更新:

根据我的研究,似乎找不到从 ACS 容器内的主机挂载 /var/run/docker.sock 的方法,例如此线程中提到的问题:Mounting volume in Azure-Container-Service not working for traefik.toml and /var/run/docker.sock