buildkite-plugins / docker-buildkite-plugin

🐳📦 Run any build step in a Docker container
MIT License
113 stars 106 forks source link

mount-buildkite-agent on Windows fails with invalid volume specification #157

Closed petemounce closed 2 years ago

petemounce commented 4 years ago
C:\Program Files\docker\docker.exe: Error response from daemon: invalid volume specification: '/c/program files/buildkite-agent/buildkite-agent:/usr/bin/buildkite-agent'.

Plugin version v3.5.0.

Windows 2019 Server.

zymotik commented 4 years ago

@petemounce did you solve this or find a workaround?

zymotik commented 4 years ago

Ok, I've spotted the issue, the mapping is in the Linux style for the volumes, ie:

docker run 
    -i 
    --rm 
    --volume C:\\buildkite-agent\\builds\\build-windows\\app:c:\\app --workdir c:\\app  
    --volume /c/buildkite-agent/bin/buildkite-agent:/usr/bin/buildkite-agent 
    --label com.buildkite.job-id=some-id
    mcr.microsoft.com/windows:1809-amd64

Notice the difference between the first volume mapping and the second one which is causing the failure with:

C:\Program Files\Docker\docker.exe: Error response from daemon: invalid volume specification: '/c/buildkite-agent/bin/buildkite-agent:/usr/bin/buildkite-agent'.

petemounce commented 4 years ago

My workaround was to mount the directory containing the binary into a directory in the PATH within my container via a volume, and then also -e the token for auth.

zymotik commented 4 years ago

Thanks @petemounce, that worked for me too. I also added the necessary env tokens:

  - label: "Create package"
    artifact_paths:
      - "./output/**/*"
    plugins:
      - docker#v3.5.0:
          image: mcr.microsoft.com/powershell:windowsservercore-1809
          environment:
            - BUILDKITE_JOB_ID
            - BUILDKITE_BUILD_ID
            - BUILDKITE_AGENT_ACCESS_TOKEN
          workdir: c:\app
          volumes: 
            - "c:\\buildkite-agent:c:\\buildkite-agent"
#          mount-buildkite-agent: true # This fails due to a bug, workaround is to add the volume manually
          command: ["pwsh", "build\\prepare-package.ps1"]
    agents:
      queue: build.windows
toote commented 2 years ago

I have added some code that should fix this and some documentation on the matter as well. Unfortunately, I can not test the change as I don't have access to a windows agent, but I don't think I can break it even more :P