user25982998
user25982998

Reputation: 11

How to run docker daemon on windows self hosted agent through VM scale set

I'm new to dockers and I have a self hosted windows-10 VM scale set. Now from this build agent, I'm trying to run the docker build and it is failing with below error on azure pipeline

error during connect: Post http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.32/images/create?fromImage=prefecthq%2Fprefect&tag=2-python3.10: open //./pipe/docker_engine: The system cannot find the file specified. In the default daemon configuration on Windows, the docker client must be run elevated to connect. This error may also indicate that the docker daemon is not running. C:\a\_tool\docker-stable\17.9.0-ce\x64\docker.exe inspect prefecthq/prefect:2-python3.10

The image is building successfully in local

Here are my yml tasks

  - task: DockerInstaller@0
    inputs:
      dockerVersion: '17.09.0-ce'
 
  - task: Docker@2
    displayName: "Docker Registry Login"
    inputs:
      containerRegistry: "$(DockerRegistryServiceEndpointName)"
      command: "login"

  - task: Docker@2
    displayName: "Build Docker Image"
    inputs:
      containerRegistry: "$(DockerRegistryServiceEndpointName)"
      repository: "$(ContainerRepository)"
      command: "build"
      Dockerfile: "**/Dockerfile"
      tags: |
        $(Build.BuildId)
        latest

I tried to see if docker version is working and even for that, I get same error

To run the daemon I used below command but it is not working through pipeline saying docker is not found.

- powershell: |
      Start-Service docker
      docker version

I'm not sure whether if we can run the docker in elevated mode through yml.

Upvotes: 0

Views: 203

Answers (1)

Bright Ran-MSFT
Bright Ran-MSFT

Reputation: 13444

By default, the VMSS will not automatically install Docker by default if the image you select to set up the VMSS does not have Docker installed.

For your case, since you are using Windows 10 VM, it is recommended to install Docker Desktop on the VM.

  1. Before installing Docker, ensure you have enabled Nested Virtualization and installed WSL on the VM.

  2. After successfully enabling Nested Virtualization and WSL, you can install Docker Desktop on the VM.

  3. Docker Desktop does not start automatically after installation. So, you also need to start it.

You can use the Custom Script Extension to run a script to do above steps:

  • The documentations I shared above have provided the command lines to enable Nested Virtualization and WSL.

  • The documentation "Install Docker Desktop on Windows" provides the command lines to install Docker Desktop on Windows.

  • By default, the Docker Desktop is installed at "C:\Program Files\Docker\Docker\Docker Desktop.exe". You can use the command to start it. For example.

    Start-Process -FilePath "C:\Program Files\Docker\Docker\Docker Desktop.exe"
    

Upvotes: 1

Related Questions