We've recently reconfigured our build process to run entirely in containers, and we're now looking to migrate away from on-premise build agents to using agents in an Azure Scale Set.
We want to avoid having to maintain our own VM images for the Azure Scale Set, and have opted to use the default Ubuntu 18.04 LTS image which is available in Azure.
This image does not include Docker, so we've configured the Azure Scale Set to use a cloud-config script which will install Docker when the VM first boots:
#cloud-config
apt:
sources:
docker.list:
source: deb [arch=amd64] https://download.docker.com/linux/ubuntu $RELEASE stable
keyid: 9DC858229FC7DD38854AE2D88D81803C0EBFCD88
packages:
- docker-ce
- docker-ce-cli
groups:
- docker
This seems to work well, but sometimes the build jobs fail:
Starting: Initialize containers
/usr/bin/docker version --format '{{.Server.APIVersion}}'
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
'
##[error]Exit code 1 returned from process: file name '/usr/bin/docker', arguments 'version --format '{{.Server.APIVersion}}''.
Finishing: Initialize containers
It looks like either the cloud-init script failed, or the Azure DevOps agent started on the VM before the cloud-init script completed.
So far, I've seen the following scenarios:
- Provisioning a new VM works fine, and the jobs run correctly
- The first few jobs fail on a newly provisioned VM, and then run correctly. (Perhaps because the cloud-init script ran in parallel with Azure DevOps extension which deploys the agent to the VM, and you have a race condition?)
- All jobs fail, even after say 30 minutes. Sometimes reimagining the VM helps, sometimes it does not.
Does anyone have a similar setup? Does it work properly? If not, what are alternative ways to deploy Docker to the VMs before the VM runs a container job?
sometimes
? Was the VM running when you run the pipeline? Though this issue seems to be more related to the setup in your VM, could you share some details about your pipeline? – LoLanceInitialize containers
step fails cause your VM was not correctly started, so azure devops failed atInitialize containers
with errorIs the docker daemon running?
. The cause of this issue seems to come from Azure VM side which I'm not familiar with... – LoLance