impllementing D drrive on container agent

tarun k 555 Reputation points
2025-07-09T08:36:00.1833333+00:00

I am planning to create D drive which is for docker windows container and later it will be POD and then it will be used as a self hosted agent to run pipeline

How it can be done?

Azure DevOps
{count} votes

2 answers

Sort by: Most helpful
  1. Durga Reshma Malthi 9,840 Reputation points Microsoft External Staff Moderator
    2025-07-09T09:31:57.35+00:00

    Hi tarun k

    To create a D drive for Docker Windows containers that will eventually be used inside a Kubernetes Pod as a self-hosted Azure DevOps agent, please follow the below steps:

    Create D Drive on Windows Host:

    • Open Disk Management -> Win + R -> type diskmgmt.msc -> Action -> Create VHD -> Set a location (e.g., C:\DockerData.vhdx), Set size (e.g., 100GB) and choose VHDX format and Dynamically Expanding type.
    • Right-click the newly created disk -> Initialize and create a new simple volume and assign drive letter D. Now you have a D: drive available for Docker.

    Configure Docker to Use D: for Windows Containers:

    • Stop Docker (if running): Stop-Service docker
    • Move Docker data directory to D, by default, Docker uses C:\ProgramData\Docker. You can reconfigure Docker to store images/containers on D:
        mkdir D:\DockerData
        move "C:\ProgramData\Docker" "D:\DockerData"
      
    • Create or edit C:\ProgramData\Docker\config\daemon.json:
        {
          "data-root": "D:\\DockerData"
        }
      
    • Restart Docker by running: Start-Service docker

    Containerize the Self-Hosted Azure DevOps Agent (Windows):

    Once Docker is set up to use D:, you can build your Windows-based self-hosted agent container.

    Example Dockerfile (Windows):

    FROM mcr.microsoft.com/windows/servercore:ltsc2022
    # Add tools and agent files
    SHELL ["powershell", "-Command"]
    RUN Invoke-WebRequest -Uri https://vstsagentpackage.azureedge.net/agent/3.236.0/vsts-agent-win-x64-3.236.0.zip -OutFile agent.zip; \
        Expand-Archive agent.zip -DestinationPath C:\azagent; \
        Remove-Item agent.zip
    WORKDIR C:\azagent
    # Entry script for agent
    COPY start.ps1 .
    CMD ["powershell.exe", "C:\\azagent\\start.ps1"]
    
    #start.ps1 script:
    $env:AZP_URL = "https://dev.azure.com/<org>"
    $env:AZP_TOKEN = "<PAT>"
    $env:AZP_AGENT_NAME = "docker-agent"
    $env:AZP_POOL = "docker-pool"
    .\config.cmd --unattended --url $env:AZP_URL --auth pat --token $env:AZP_TOKEN --pool $env:AZP_POOL --agent $env:AZP_AGENT_NAME --acceptTeeEula --runAsService
    .\run.cmd
    

    Later, if you're planning to deploy this Docker image as a Kubernetes Pod (e.g., in AKS),

    • Create PVC:
        apiVersion: v1
        kind: PersistentVolumeClaim
        metadata:
          name: docker-agent-pvc
        spec:
          accessModes:
            - ReadWriteOnce
          resources:
            requests:
              storage: 50Gi
      
    • Deployment YAML Example:
        apiVersion: apps/v1
        kind: Deployment
        metadata:
          name: docker-agent
        spec:
          replicas: 1
          selector:
            matchLabels:
              app: docker-agent
          template:
            metadata:
              labels:
                app: docker-agent
            spec:
              containers:
                - name: agent
                  image: <your-container-registry>/windows-docker-agent:latest
                  volumeMounts:
                    - name: docker-volume
                      mountPath: /azagent
              volumes:
                - name: docker-volume
                  persistentVolumeClaim:
                    claimName: docker-agent-pvc
      

    Additional References:

    https://stackoverflow.com/questions/73955158/cannot-mount-volume-for-drive-d-or-e-in-docker-desktop-for-windows

    Hope this helps!

    Please Let me know if you have any queries.


  2. Durga Reshma Malthi 9,840 Reputation points Microsoft External Staff Moderator
    2025-08-08T10:40:46.6366667+00:00

    Hi tarun k

    As you have asked in private message about "is there any way to use D drive for AKS agent pools? any office document which describes the process?"

    Using a D drive for Azure Kubernetes Service (AKS) agent pools is not a standard configuration, as AKS typically uses ephemeral storage for its nodes.

    However, you can attach additional managed disks to your AKS nodes to provide persistent storage for your workloads.

    But there is no official Microsoft documentation.

    And I have seen your previous thread related to this - https://learn.microsoft.com/en-us/answers/questions/4370485/using-creating-d-drive-in-container-and-then-later

    Could you please check the response.

    Hope this helps!

    Please Let me know if you have any queries.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.