jenkinsci / jenkinsci/docker-workflow-plugin

[JENKINS-56883] Docker proxy is not set if it matches the host proxy

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

Description

I found a bug that doesn't let me set the company proxy inside a docker container because it is defined on the host as well.

environment variable on the host:

https_proxy=mycompany.de:8080


 

pipeline {

agent {
label 'master'
}
stages {
stage('Azure Docker Image Build') {
steps {
withDockerContainer('microsoft/azure-cli') {
withEnv(['HTTPS_PROXY=mycompany.de:8080']) {
sh 'env'
}
}
}
}
}
}

I think the origin of this bug is this line: https://github.com/jenkinsci/docker-workflow-plugin/blob/648f335899c5229fb8a6e889739db9cfb15de890/src/main/java/org/jenkinsci/plugins/docker/workflow/WithContainerStep.java#L130

Where every enivronment variable that matches the host variables is removed.

Currently the workaround is to explicitly set the environment variable:

withDockerContainer(args: '-e HTTPS_PROXY=mycompany.de:8080', image: 'microsoft/azure-cli') {

// some block
}

---
Originally reported by xaseron, imported from: Docker proxy is not set if it matches the host proxy


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

Raw content of original issue

I found a bug that doesn't let me set the company proxy inside a docker container because it is defined on the host as well.

environment variable on the host:



https_proxy=mycompany.de:8080



 



pipeline {

agent {
label 'master'
}
stages {
stage('Azure Docker Image Build') {
steps {
withDockerContainer('microsoft/azure-cli') {
withEnv(['HTTPS_PROXY=mycompany.de:8080']) {
sh 'env'
}
}
}
}
}
}


I think the origin of this bug is this line: https://github.com/jenkinsci/docker-workflow-plugin/blob/648f335899c5229fb8a6e889739db9cfb15de890/src/main/java/org/jenkinsci/plugins/docker/workflow/WithContainerStep.java#L130

Where every enivronment variable that matches the host variables is removed.

Currently the workaround is to explicitly set the environment variable:



withDockerContainer(args: '-e HTTPS_PROXY=mycompany.de:8080', image: 'microsoft/azure-cli') {

// some block
}

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.