jenkinsci / jenkinsci/docker-workflow-plugin

[JENKINS-61743] Customizable workspace and working directory of docker.images.inside()

Open
#646 2 comments 0 reactions 0 assignees View on GitHub
component:docker-workflow-plugin enhancement imported-jira-issue priority:major resolution:unresolved
Dominant language
Java
Stars
527
Forks
422
Avg merge
10m
Merged PRs (30d)
1

Description

Hello,

I want to have a possibility to change the "workdir" & "volume" destination directory within the image which will be started by the "docker.image.inside"-command.

The current problem is that the path to the mount-destination within the container and the working directory are hard-coded:

Hard-coded volumes:


Hard-coded Work-Dir (parameter 4 is always "ws" == "workspace"):


So the "default" image.inside command (on windows) results in something like:

docker run -t -d -w ${WORKSPACE} -v ${WORKSPACE}:${WORKSPACE} -v ${WORKSPACE}@​tmp:${WORKSPACE}@​tmp


It's not "clean" because the destination in the started container is hardcoded as the same directory of the workspace. This can cause issues with rights, existing drives, and other stuff.

Feature-Request in short:

I want to have the possibility to change the working directory and the volume mounting directory which points into the started container.



  • The default behavior can be kept as it is

I have two proposals (from the user side of view) attached in (proposal.txt)

It would be nice to make the "image.inside" command will result in something like this:

docker run -t -d -w ${IMG_WORK_DIR} -v ${HOST_WORKSPACE}:${IMG_WORKSPACE} -v ${HOST_WORKSPACE}@​tmp:${IMG_WORKSPACE}@​tmp


  

Background how I ran into this:

My System is a Jenkins-Master on a Linux-Server. I have two Slaves one Linux & one Windows.



  • all this are real physical machines, no VM's or other stuff

  • The Windows-Slave has a Windows-Server 2016 OS

In my case the "workspace" of Jenkins is on the "E"-Drive.

If you run the attached "example.txt" you can reproduce the error on every jenkins



  • of course on my machine, dont need the "ws(...)" part

The Error is an error on the docker run command because docker is unable to create a new Drive, as mounting point in the created container.



  • I tried very much to create a "E"-Drive as volume in the Image, but I wasn't able to make it

    • I tried symlinks, registry changes and stuff ...



  • after all this I looked into the Code of the Plugin and thought this should be changeable ...

All in all I think the origin of the problem are the hard-coded directories within the containers.

---
Originally reported by tharilya, imported from: Customizable workspace and working directory of docker.images.inside()


  • status: Open
  • priority: Major
  • component(s): docker-workflow-plugin
  • resolution: Unresolved
  • votes: 4
  • watchers: 6
  • imported: 2025-12-07

Raw content of original issue

Hello,

I want to have a possibility to change the "workdir" & "volume" destination directory within the image which will be started by the "docker.image.inside"-command.

The current problem is that the path to the mount-destination within the container and the working directory are hard-coded:
Hard-coded volumes:


Hard-coded Work-Dir (parameter 4 is always "ws" == "workspace"):


So the "default" image.inside command (on windows) results in something like:



docker run -t -d -w ${WORKSPACE} -v ${WORKSPACE}:${WORKSPACE} -v ${WORKSPACE}@tmp:${WORKSPACE}@tmp



It's not "clean" because the destination in the started container is hardcoded as the same directory of the workspace. This can cause issues with rights, existing drives, and other stuff.

Feature-Request in short:
I want to have the possibility to change the working directory and the volume mounting directory which points into the started container.



  • The default behavior can be kept as it is

I have two proposals (from the user side of view) attached in (proposal.txt)

It would be nice to make the "image.inside" command will result in something like this:



docker run -t -d -w ${IMG_WORK_DIR} -v ${HOST_WORKSPACE}:${IMG_WORKSPACE} -v ${HOST_WORKSPACE}@tmp:${IMG_WORKSPACE}@tmp



  

Background how I ran into this:
My System is a Jenkins-Master on a Linux-Server. I have two Slaves one Linux & one Windows.



  • all this are real physical machines, no VM's or other stuff

  • The Windows-Slave has a Windows-Server 2016 OS

In my case the "workspace" of Jenkins is on the "E"-Drive.
If you run the attached "example.txt" you can reproduce the error on every jenkins



  • of course on my machine, dont need the "ws(...)" part

The Error is an error on the docker run command because docker is unable to create a new Drive, as mounting point in the created container.



  • I tried very much to create a "E"-Drive as volume in the Image, but I wasn't able to make it

    • I tried symlinks, registry changes and stuff ...



  • after all this I looked into the Code of the Plugin and thought this should be changeable ...

All in all I think the origin of the problem are the hard-coded directories within the containers.

environment

```
Jenkins: 2.190.1

docker-workflow-plugin: 1.23

Linux-Machine (2-Cores - Master, others for Linux-Slave):

Linux 3.10.0-1062.12.1.e17.x86_x64 GNU/Linux

Windows-Machine:

OS Name: Microsoft Windows Server 2016 Datacenter

OS Version: 10.0.14393 N/A Build 14393
```

2 attachments

- [example.txt](https://issues.jenkins.io/secure/attachment/50837/example.txt)
- [proposal.txt](https://issues.jenkins.io/secure/attachment/50838/proposal.txt)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.