jenkinsci / jenkinsci/docker-workflow-plugin

[JENKINS-70894] Agent args cannot override default config on plugin

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

Description

When using agent docker into a jenkinsfile we can add some args to our file, like user, volume or other. 

The actual behaviour when docker container start working is:

[Pipeline] withDockerContainerJenkins does not seem to be running inside a container$ docker run -t -d -u 995:993 -w /var/lib/jenkins/workspace/Test/test-docker -v /var/lib/jenkins/workspace/Test/test-docker:/var/lib/jenkins/workspace/Test/test-docker:rw,z -v /var/lib/jenkins/workspace/Test/test-docker@​tmp:/var/lib/jenkins/workspace/Test/test-docker@​tmp:rw,z -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 ******** registry.gitlab.com/path/to/my/images/image:latest cat 

However if on the jenkinsfile we set some args for user or volume, the expected behaviour should be to override the default ones, but instead is just adding more args to the docker run command:

the jenkinsfile:

pipeline {

    agent { 
        docker {
            image 'path/to/my/images/image:latest'
            registryUrl 'https://registry.gitlab.com'
            args '-u 995:1000'
        }
    }

The output:

[Pipeline] withDockerContainerJenkins does not seem to be running inside a container$ docker run -t -d -u 995:993 -u 995:1000 -w /var/lib/jenkins/workspace/Test/test-docker -v /var/lib/jenkins/workspace/Test/test-docker:/var/lib/jenkins/workspace/Test/test-docker:rw,z -v /var/lib/jenkins/workspace/Test/test-docker@​tmp:/var/lib/jenkins/workspace/Test/test-docker@​tmp:rw,z -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 ******** registry.gitlab.com/path/to/my/images/image:latest cat

This creates limitation for the plugin and does not allow to use all the power of docker.

 

Possible solution:



  • set a way to override the default values or to do more configuration for the plugin


  • create some condition that if the jenkinsfile contains some args, do not set the default one but use the ones provided on the Jenkinsfile

---
Originally reported by sdeponte, imported from: Agent args cannot override default config on plugin


  • status: Open
  • priority: Minor
  • component(s): docker-workflow-plugin
  • resolution: Unresolved
  • votes: 1
  • watchers: 2
  • imported: 2025-12-07

Raw content of original issue

When using agent docker into a jenkinsfile we can add some args to our file, like user, volume or other. 

The actual behaviour when docker container start working is:



[Pipeline] withDockerContainerJenkins does not seem to be running inside a container$ docker run -t -d -u 995:993 -w /var/lib/jenkins/workspace/Test/test-docker -v /var/lib/jenkins/workspace/Test/test-docker:/var/lib/jenkins/workspace/Test/test-docker:rw,z -v /var/lib/jenkins/workspace/Test/test-docker@tmp:/var/lib/jenkins/workspace/Test/test-docker@tmp:rw,z -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 ******** registry.gitlab.com/path/to/my/images/image:latest cat 

However if on the jenkinsfile we set some args for user or volume, the expected behaviour should be to override the default ones, but instead is just adding more args to the docker run command:
the jenkinsfile:



pipeline {

    agent { 
        docker {
            image 'path/to/my/images/image:latest'
            registryUrl 'https://registry.gitlab.com'
            args '-u 995:1000'
        }
    }


The output:



[Pipeline] withDockerContainerJenkins does not seem to be running inside a container$ docker run -t -d -u 995:993 -u 995:1000 -w /var/lib/jenkins/workspace/Test/test-docker -v /var/lib/jenkins/workspace/Test/test-docker:/var/lib/jenkins/workspace/Test/test-docker:rw,z -v /var/lib/jenkins/workspace/Test/test-docker@tmp:/var/lib/jenkins/workspace/Test/test-docker@tmp:rw,z -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 ******** registry.gitlab.com/path/to/my/images/image:latest cat


This creates limitation for the plugin and does not allow to use all the power of docker.

 

Possible solution:



  • set a way to override the default values or to do more configuration for the plugin


  • create some condition that if the jenkinsfile contains some args, do not set the default one but use the ones provided on the Jenkinsfile


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.