jenkinsci / jenkinsci/docker-plugin
"MAC Address" field has no effect
- Dominant language
- Java
- Stars
- 498
- Forks
- 324
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 2
Description
### Jenkins and plugins versions report
Environment
```text
Jenkins: 2.568.1
OS: Linux - 6.8.0-136-generic
Java: 25.0.3 - Eclipse Adoptium (OpenJDK 64-Bit Server VM)
---
analysis-model-api:14.14.0-1004.vf53c9efb_f455
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.6.2-199.vc3c04d033fcc
asm-api:9.10.1-216.va_9256d3b_844b_
authentication-tokens:1.144.v5ff4a_5ec5c33
blueocean:1.27.25
blueocean-bitbucket-pipeline:1.27.25
blueocean-commons:1.27.25
blueocean-config:1.27.25
blueocean-core-js:1.27.25
blueocean-dashboard:1.27.25
blueocean-display-url:2.4.4
blueocean-events:1.27.25
blueocean-git-pipeline:1.27.25
blueocean-github-pipeline:1.27.25
blueocean-i18n:1.27.25
blueocean-jwt:1.27.25
blueocean-personalization:1.27.25
blueocean-pipeline-api-impl:1.27.25
blueocean-pipeline-editor:1.27.25
blueocean-pipeline-scm-api:1.27.25
blueocean-rest:1.27.25
blueocean-rest-impl:1.27.25
blueocean-web:1.27.25
bootstrap5-api:5.3.8-1048.va_c299057e35c
bouncycastle-api:2.30.1.84-291.v9f17b_21896e2
branch-api:2.1280.v0d4e5b_b_460ef
build-timeout:1.40
caffeine-api:3.2.4-208.v7e2da_a_7db_82b_
checks-api:415.vf022234a_931d
cloud-stats:423.v63f017a_f582c
cloudbees-bitbucket-branch-source:937.3.6
cloudbees-folder:6.1106.v3a_d9a_6d2465e
commons-collections4-api:4.5.0-8.va_d5448ef9011
commons-compress-api:1.28.0-86.v905b_77d84797
commons-lang3-api:3.20.0-109.ve43756e2d2b_4
commons-text-api:1.15.0-218.va_61573470393
conditional-buildstep:1.5.0
configuration-as-code:2114.v67a_a_18696b_8f
coverage:3.3311.v42c5a_f929e3e
credentials:1506.v948b_b_b_7dec44
credentials-binding:728.v902a_273b_8947
dark-theme:652.vea_da_dfea_e769
data-tables-api:2.3.8-1570.v1cb_1cd2a_0fb_c
display-url-api:2.217.va_6b_de84cc74b_
docker-commons:477.v289085a_b_6896
docker-java-api:3.7.1-136.v5d70f77a_c3d6
docker-plugin:1324.v2fb_b_df97fe1d
dtkit-api:3.0.3
durable-task:686.v80ff80875b_82
echarts-api:6.1.0-1306.vcee1648c16a_4
eddsa-api:0.3.0.1-29.v67e9a_1c969b_b_
email-ext:2038.v7b_8817a_499d9
envinject:2.941.v351a_20c0a_3ca_
envinject-api:1.241.vdd714803b_403
favorite:2.267.vb_90d08408081
font-awesome-api:7.3.1-1013.v0835a_879ec6d
forensics-api:4.1891.v5e60f3377506
git:5.10.1
git-client:6.6.1
github:1.47.0
github-api:1.330-492.v3941a_032db_2a_
github-branch-source:1967.1970.vd86979736546
gitlab-plugin:1.9.16
gson-api:2.14.0-201.v8eefe5515533
handy-uri-templates-2-api:2.1.8-38.vcea_5d521d5f3
htmlpublisher:427.1
instance-identity:203.v15e81a_1b_7a_38
ionicons-api:94.vcc3065403257
jackson-annotations2-api:2.22-19.v10a_a_582ea_26e
jackson2-api:2.22.1-443.vc91f592333c4
jackson3-api:3.2.1-92.vd25c2e23c180
jakarta-activation-api:2.1.4-1
jakarta-mail-api:2.1.5-1
jakarta-xml-bind-api:4.0.9-19.v2b_a_5b_44d9a_1c
javax-activation-api:1.2.0-8
jaxb:2.3.9-143.v5979df3304e6
jenkins-design-language:1.27.25
jersey3-api:3.1.11-4.v77818819c2e1
jjwt-api:0.13.0-141.vd58b_a_9592b_6c
joda-time-api:2.14.3-200.v65623733c99f
jquery3-api:3.7.1-687.v68d468e40b_30
json-api:20260719-223.va_81f828cdb_58
json-path-api:3.0.0-218.vcd4dd1355de2
jsoup:1.23.1-103.v4fde9422cc6f
junit:1416.vd753e036de5e
ldap:807.809.vd3a_4e5e4ec98
lockable-resources:1539.v4db_b_fc1cc115
mailer:534.v1b_36f5864073
mapdb-api:1.0.9-44.va_1e1310c9118
matrix-auth:3.3
matrix-project:905.vcc6831e8760a_
mina-sshd-api-common:2.17.1-187.v0341274c2905
mina-sshd-api-core:2.17.1-187.v0341274c2905
next-build-number:66.v4b_4762172d53
okhttp-api:5.3.2-200.vedb_720a_cf1f8
pipeline-build-step:599.v4b_67ea_11b_152
pipeline-graph-analysis:254.v0f63a_a_447dca_
pipeline-graph-view:980.vb_db_0b_e5f683c
pipeline-groovy-lib:798.v5cc688825312
pipeline-input-step:560.v56198a_642157
pipeline-milestone-step:152.v6e22b_8cfc66c
pipeline-model-api:2.2291.v2934911987b_6
pipeline-model-definition:2.2291.v2934911987b_6
pipeline-model-extensions:2.2291.v2934911987b_6
pipeline-stage-step:345.va_96187909426
pipeline-stage-tags-metadata:2.2291.v2934911987b_6
plain-credentials:199.v9f8e1f741799
plugin-util-api:7.1341.v039f146993d9
prism-api:1.30.0-741.v034eb_0b_0a_a_fa_
pubsub-light:1.19
resource-disposer:0.25
run-condition:276.v97298f3a_cd51
scm-api:728.vc30dcf7a_0df5
script-security:1402.1405.vc96e74964250
sloccount:1.27
snakeyaml-api:2.5-149.v72471e9c6371
snakeyaml-engine-api:3.0.1-5.vd98ea_ff3b_92e
sse-gateway:1.29
ssh-credentials:372.va_250881b_08cd
ssh-slaves:3.1097.v868116049892
structs:362.va_b_695ef4fdf9
subversion:1303.vcfd9679fb_c12
theme-manager:346.v06cca_64c6a_37
timestamper:1.30
token-macro:477.vd4f0dc3cb_cf1
trilead-api:2.284.v1974ea_324382
variant:70.va_d9f17f859e0
warnings-ng:13.10153.v011f47a_3ef01
woodstox-core-api:7.2.1-6.v3718a_a_11f5c4
workflow-aggregator:608.v67378e9d3db_1
workflow-api:1413.v2ff1a_5e720fa_
workflow-basic-steps:1098.v808b_fd7f8cf4
workflow-cps:4360.v2020e8819a_d6
workflow-durable-task-step:1479.v56e587f413a_7
workflow-job:1590.v49101d088542
workflow-multibranch:841.vec5b_9e1806ec
workflow-scm-step:466.va_d69e602552b_
workflow-step-api:724.v538c2362b_dfb_
workflow-support:1015.v785e5a_b_b_8b_22
ws-cleanup:0.49
xunit:3.1.7
```
### What Operating System are you using (both controller, and any agents involved in the problem)?
server ubuntu 24.04
jenkins master docker image jenkins/jenins:lts-jdk25
container/agent based on docker image jenkins/agent:jdk25
### Reproduction steps
1. create a docker cloud in jenkins
2. add a image template and specify the MAC Address field
3. run a dummy pipeline to check if the mac address got propagated:
```
pipeline {
agent { label 'some-label'}
stages {
stage('Hello') {
steps {
echo 'Hello World'
}
}
stage('MAC') {
steps {
sh'''
# ip -br -o link # ip command isn't present on all images, so lets use /sys instead
cat /sys/class/net/*/address
# wait for a while so one could also use "docker inspect" on the container before it gets removed
sleep 120
'''
}
}
}
}
```
### Expected Results
The container should now have the mac address specified
### Actual Results
docker generates a random local mac address for the container
### Anything else?
To debug this issue, i traced the docker socket and also started dockerd with --debug. Here are my findings:
1. The API Call actually passes the MAC Address.
2. Here's what you can find in the json at root level (shortened):
```json
"HostConfig": {
"NetworkMode": null,
},
"MacAddress": "00:11:22:33:44:55",
"NetworkDisabled": null,
"NetworkingConfig": null,
```
3. The docker API says, MacAddress is deprecated
4. Docker inspect doen't show the MAC address
Possible way for a bugfix:
1. i hand-crafted a API call and passed it via curl
2. the change is that i specified a "NetworkingConfig" which contains the desired MAC Address
3. i
4. Here's how it looks like
```
curl -X POST --unix-socket /var/run/docker.sock http://localhost/v1.44/containers/create \
-H "Content-Type: application/json" \
-d '{
"Image": "my-local-image-name:latest",
"Cmd": ["/bin/sh"],
"Tty": true,
"Hostname": null,
"Env": [
"SOME_VAR=value"
],
"Labels": {
"com.nirima.jenkins.plugins.docker.JenkinsContainerImage": "my-local-image-name:latest",
"com.nirima.jenkins.plugins.docker.JenkinsId": "manual-test-override",
"com.nirima.jenkins.plugins.docker.JenkinsNodeName": "ManualTestNode",
"com.nirima.jenkins.plugins.docker.JenkinsServerUrl": "https://my.jenkins.server/",
"com.nirima.jenkins.plugins.docker.JenkinsTemplateName": "My Templatename"
},
"HostConfig": {
"Binds": null,
"Mounts": [
{
"Source": "/some/source",
"Target": "/some/target",
"Type": "bind"
}
],
"Privileged": false,
"NetworkMode": "bridge"
},
"NetworkingConfig": {
"EndpointsConfig": {
"bridge": {
"IPAMConfig": {},
"MacAddress": "00:11:22:33:44:55"
}
}
}
}'
```
### Are you interested in contributing a fix?
i've no java experience, so i guess this is not a job for me :( but i'd be happy to contribute testing
Contributor guide
Research direction
Start at Docker container creation for image templates and trace how the template's MAC Address becomes the request JSON. Compare the current deprecated root-level MacAddress with the reported NetworkingConfig/EndpointsConfig form, then verify completion by reproducing the pipeline and confirming the container receives the specified address.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, java
- Domain
- cloud, devops, infrastructure
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100