Skip to content

Can't run docker("<image>").inside { } on a Windows slave where workspace is located on a different drive than C:\ #1166

@enaess

Description

@enaess

Jenkins and plugins versions report

Environment
Jenkins: 2.516.2
OS: Linux - 6.8.0-79-generic
Java: 21.0.8 - Amazon.com Inc. (OpenJDK 64-Bit Server VM)
---
active-directory:2.40
analysis-model-api:13.8.0-902.v26f80296f743
ant:518.v8d8dc7945eca_
antisamy-markup-formatter:173.v680e3a_b_69ff3
apache-httpcomponents-client-4-api:4.5.14-269.vfa_2321039a_83
apache-httpcomponents-client-5-api:5.5-166.v870a_96374f91
asm-api:9.8-163.vb_2a_96d3f9c3c
authentication-tokens:1.144.v5ff4a_5ec5c33
authorize-project:2.0.0
azure-credentials:357.v6447d38fb_007
azure-sdk:243.v4a_0d23a_c71a_7
bootstrap5-api:5.3.7-860.v1251c115c90c
bouncycastle-api:2.30.1.81-264.v95c79c0e772c
branch-api:2.1244.vf95c81f1641c
build-timeout:1.38
caffeine-api:3.2.2-178.v353b_8428ed56
checks-api:373.vfe7645102093
cloud-stats:377.vd8a_6c953e98e
cloudbees-folder:6.1040.v8a_e6330a_54e3
command-launcher:123.v37cfdc92ef67
commons-compress-api:1.28.0-1
commons-lang3-api:3.18.0-98.v3a_674c06072d
commons-text-api:1.14.0-194.v804a_dc3a_1b_d8
credentials:1419.v2337d1ceceef
credentials-binding:702.vfe613e537e88
dark-theme:574.va_19f05d54df5
data-tables-api:2.3.3-1383.va_5607a_a_3f3c2
display-url-api:2.217.va_6b_de84cc74b_
docker-commons:457.v0f62a_94f11a_3
docker-java-api:3.5.3-122.v156e51f30c0a_
docker-plugin:1274.vc0203fdf2e74
docker-workflow:621.va_73f881d9232
dtkit-api:3.0.3
durable-task:595.ve87b_f1318d67
echarts-api:6.0.0-1146.v5c8f3b_8f0573
eddsa-api:0.3.0.1-19.vc432d923e5ee
email-ext:1925.v1598902b_58dd
emailext-template:233.v1eb_88fc160b_5
folder-properties:62.v1636b_4a_84608
font-awesome-api:7.0.0-851.vd1feb_218a_a_63
forensics-api:3.1754.v2a_6613b_77002
git:5.7.0
git-client:6.3.3
github:1.45.0
github-api:1.330-492.v3941a_032db_2a_
github-branch-source:1848.v42f74f7f4500
gradle:2.16.1149.v711b_998b_0532
gson-api:2.13.1-153.vb_3d0c48a_a_b_4a_
http_request:1.20
instance-identity:203.v15e81a_1b_7a_38
ionicons-api:94.vcc3065403257
jackson2-api:2.20.0-411.v6ef8fdee4fe9
jakarta-activation-api:2.1.3-2
jakarta-mail-api:2.1.3-3
javax-activation-api:1.2.0-8
javax-mail-api:1.6.2-11
jaxb:2.3.9-133.vb_ec76a_73f706
jdk-tool:83.v417146707a_3d
jfrog:1.5.10
jjwt-api:0.11.5-120.v0268cf544b_89
joda-time-api:2.14.0-149.v1c3ce991d1b_9
jquery3-api:3.7.1-594.vb_3864f326cf0
json-api:20250517-173.v596efb_962a_31
json-path-api:2.9.0-190.veefca_05d5477
jsoup:1.21.2-66.v6ea_38164b_8a_2
junit:1355.v45e2ea_65863c
ldap:780.vcb_33c9a_e4332
mailer:522.va_995fa_cfb_8b_d
matrix-auth:3.2.8
matrix-project:856.v4c352b_3a_b_23e
metrics:4.2.33-484.v2fcd689980d1
mina-sshd-api-common:2.16.0-167.va_269f38cc024
mina-sshd-api-core:2.16.0-167.va_269f38cc024
netty-api:4.1.118.Final-9.v776038d601a_7
okhttp-api:4.11.0-189.v976fa_d3379d6
p4:1.17.2
pam-auth:1.12
pipeline-build-step:571.v08a_fffd4b_0ce
pipeline-github-lib:65.v203688e7727e
pipeline-graph-analysis:245.v88f03631a_b_21
pipeline-graph-view:637.vb_6105ed84508
pipeline-groovy-lib:752.vdddedf804e72
pipeline-input-step:534.v352f0a_e98918
pipeline-milestone-step:138.v78ca_76831a_43
pipeline-model-api:2.2265.v140e610fe9d5
pipeline-model-definition:2.2265.v140e610fe9d5
pipeline-model-extensions:2.2265.v140e610fe9d5
pipeline-stage-step:322.vecffa_99f371c
pipeline-stage-tags-metadata:2.2265.v140e610fe9d5
pipeline-utility-steps:2.19.0
plain-credentials:199.v9f8e1f741799
plugin-util-api:6.1167.v022176c7e0ca_
prism-api:1.30.0-609.vf0a_df102d9a_f
resource-disposer:0.25
role-strategy:799.v5b_e7b_ecc231e
scm-api:707.v749f968369d4
script-security:1378.vf25626395f49
slack:795.v4b_9705b_e6d47
snakeyaml-api:2.3-125.v4d77857a_b_402
ssh-agent:386.v36cc0c7582f0
ssh-credentials:361.vb_f6760818e8c
ssh-slaves:3.1071.v0d059c7b_c555
sshd:3.374.v19b_d59ce6610
structs:353.v261ea_40a_80fb_
theme-manager:319.v9193461f9671
timestamper:1.30
token-macro:477.vd4f0dc3cb_cf1
trilead-api:2.209.v0e69b_c43c245
variant:70.va_d9f17f859e0
warnings-ng:12.9783.ve1cb_9f060738
workflow-aggregator:608.v67378e9d3db_1
workflow-api:1384.vdc05a_48f535f
workflow-basic-steps:1079.vce64b_a_929c5a_
workflow-cps:4183.v94b_6fd39da_c1
workflow-durable-task-step:1452.v0ee719c104a_7
workflow-job:1546.v62a_c59c112dd
workflow-multibranch:811.vcd33d074c2a_0
workflow-scm-step:437.v05a_f66b_e5ef8
workflow-step-api:706.v518c5dcb_24c0
workflow-support:976.vb_d9493c2eb_09
ws-cleanup:0.49
ws-ws-replacement:1.0.1
xunit:3.1.5

What Operating System are you using (both controller, and any agents involved in the problem)?

The controller is running latest jenkins w/all plugins updated to latest version. The build is dispatched onto a Win2K22 node with Java 21 and latest version of docker installed.

The windows slave is provisioned to have 1TB of disk space on E: (different than it's OS installed on C:). This E: drive is used for docker data directory and the Jenkins' workspace.

Reproduction steps

Create a new pipeline job on the controller. Paste in the following pipeline script

pipeline
{
    agent {
        label "windows"
    }
    stages {
        stage("Test") {
            steps {
                script {
                    def status = 0
                    docker.image("https://my-registry.com/test-repository/test-builder:windows-20250910").inside {
                        status = powershell(returnStatus: true, script: ''' 
                            $ErrorActionPreference = 'Stop';
                            java --version
                            '''
                        )   
                    }
                    if (status != 0) {
                        error("Tests failed")
                    }                 
                }
            }
        }
    }
}

The build logs demonstrates:

node-win-01 does not seem to be running inside a container
$ docker run -d -t -w E:/Jenkins/workspace/Test_-_Docker/ -v E:/Jenkins/workspace/Test_-_Docker/:E:/Jenkins/workspace/Test_-_Docker/ -v E:/Jenkins/workspace/Test_-_Docker@tmp/:E:/Jenkins/workspace/Test_-_Docker@tmp/ -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** my-registry.com/test-repository/test-builder:windows-20250910 cmd.exe

The docker configuration on the host is:

type C:\ProgramData\docker\config\daemon.json
{
  "debug": false,
  "hosts": ["tcp://0.0.0.0:9999", "npipe://"],
  "group": "docker-users",
  "tlsverify": true,
  "tlscacert": "C:\\ProgramData\\docker\\certs.d\\yyyyy.crt",
  "tlscert": "C:\\ProgramData\\docker\\certs.d\\xxxx.crt",
  "tlskey": "C:\\ProgramData\\docker\\certs.d\\xxxx.key",
  "data-root": "E:\\docker"
}

Expected Results

This should be able to spin up a docker image, and run the java --version inside of it.

Actual Results

Build fails with the following obscure message:

Also:   org.jenkinsci.plugins.workflow.actions.ErrorAction$ErrorId: e73e8578-5a0f-43e5-bc87-8394b90a48db
java.io.IOException: Failed to run image 'my-registry.com/test-repository/test-builder:windows-20250910'. Error: docker: Error response from daemon: hcs::CreateComputeSystem 75d149c8144b4ca8c7f967007378e6bdf9aa247bc70bb58d06f0a76d3f4c53fa: The parameter is incorrect.
	at PluginClassLoader for docker-workflow//org.jenkinsci.plugins.docker.workflow.client.WindowsDockerClient.run(WindowsDockerClient.java:58)
	at PluginClassLoader for docker-workflow//org.jenkinsci.plugins.docker.workflow.WithContainerStep$Execution.start(WithContainerStep.java:200)
	at PluginClassLoader for workflow-cps//org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:322)
	at PluginClassLoader for workflow-cps//org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:195)
	at PluginClassLoader for workflow-cps//org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:124)
	at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:47)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
	at PluginClassLoader for workflow-cps//com.cloudbees.groovy.cps.sandbox.DefaultInvoker.methodCall(DefaultInvoker.java:20)
	at PluginClassLoader for workflow-cps//org.jenkinsci.plugins.workflow.cps.LoggingInvoker.methodCall(LoggingInvoker.java:118)
	at org.jenkinsci.plugins.docker.workflow.Docker$Image.inside(Docker.groovy:140)
	at org.jenkinsci.plugins.docker.workflow.Docker.node(Docker.groovy:66)
	at org.jenkinsci.plugins.docker.workflow.Docker$Image.inside(Docker.groovy:125)
	at org.jenkinsci.plugins.docker.workflow.Docker$Image.inside(Docker.groovy)
	at WorkflowScript.run(WorkflowScript:17)
	at ___cps.transform___(Native Method)

### Anything else?

The fact that jenkins is trying to run the container mapping E:/Jenkins to E:/Jenkins isn't working. I believe that is a known limitation to docker on windows at the moment. However, it would be nice if one could enter a fix to use 

`--mount type=bind,src=E:\Jenkins,dst=C:\Jenkins`

Should be as simple as replacing the drive letter of the destination to always be C:\ as that is a limitation of the docker itself.

### Are you interested in contributing a fix?

I have no clue to where to begin. I've looked at the docker-plugin code ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions