buildkite-plugins / docker-buildkite-plugin

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

Windows: docker: Error response from daemon: invalid volume specification #256

Open HugeIRL opened 1 year ago

HugeIRL commented 1 year ago

Elastic Stack Version: 6.0.0 OS Selection: Windows Docker Plugin version: 5.3.0 -> 5.8.0

I think we've discovered a bug in the plugin in regards to Windows and the BUILDKITE_AGENT_BINARY_PATH + mount-buildkite-agent=true settings on versions 5.3.0 -> 5.8.0 (latest).

Consider the following pipeline: (As an example. The BUILDKITE_AGENT_BINARY_PATH can be set to anything and it still fails)

steps:
  - label: "Build"
    env:
      BUILDKITE_AGENT_BINARY_PATH: "C:\\buildkite-agent"
    plugins:
    - docker#v5.8.0:
        image: helloworld:latest
        always-pull: true
        propagate-environment: true
        mount-buildkite-agent: true
    command: echo "uh oh!"

When run, you will get the following error:

docker: Error response from daemon: invalid volume specification: 'C:\buildkite-agent:C:\\buildkite-agent'.

I did some experimentation by forking the docker-buildkite-plugin and messing around with how we set the following: https://github.com/buildkite-plugins/docker-buildkite-plugin/blob/master/hooks/command#L96 https://github.com/buildkite-plugins/docker-buildkite-plugin/blob/master/hooks/command#L284

Seems to me like the format for the --volume isn't being set correctly, but I'm not entire sure what is causing it at this time.

toote commented 2 months ago

@HugeIRL from what I've read the correct configuration should be removing the double backslash from the mount path, i.e. agent_mount_folder='C:\buildkite-agent' but I don't have a windows handy to test that out.

With that said, I believe that there may be some issues with the mounting as you want to do so if the host is a windows machine but the container is not so I am unsure as to how to detect or handle that scenario as well