Skip to content

Annotations option added to hostconfig #2422

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 4, 2025
Merged

Conversation

emirhandurmus
Copy link
Contributor

Annotations opptions added to Hostconfig.
When users choose crun rather than runc and would like to deploy wasm containers, they need to provide annotations on hostconfig.

@emirhandurmus emirhandurmus requested a review from a team as a code owner April 5, 2025 12:38
@eddumelendez
Copy link
Member

Hi, thanks for your contribution. Can you add a test, please?

@emirhandurmus
Copy link
Contributor Author

emirhandurmus commented May 13, 2025

@eddumelendez test is added

@eddumelendez
Copy link
Member

thanks! test is failing

@emirhandurmus
Copy link
Contributor Author

emirhandurmus commented May 14, 2025

@eddumelendez trying to figure out why it fails. It seems to be that annotations is properly added to hostconfig, and while creating container debug logs shows annotations are added to hosthostconfig.

12:32:39.416 DEBUG c.g.d.core.command.AbstrDockerCmd - Cmd: com.github.dockerjava.core.command.CreateContainerCmdImpl@113dcaf8[aliases=,argsEscaped=,attachStderr=,attachStdin=,attachStdout=,authConfig=AuthConfig(username=githubactions, email=null, registryAddress=https://index.docker.io/v1/, stackOrchestrator=null),cmd={sleep,9999},domainName=,entrypoint=,env=,exposedPorts=ExposedPorts(exposedPorts=[]),healthcheck=,hostConfig=HostConfig(binds=[], blkioWeight=null, blkioWeightDevice=null, blkioDeviceReadBps=null, blkioDeviceWriteBps=null, blkioDeviceReadIOps=null, blkioDeviceWriteIOps=null, memorySwappiness=null, nanoCPUs=null, annotations={com.example.key2=value2, com.example.key1=value1}, capAdd=null, capDrop=null, containerIDFile=null, cpuPeriod=null, cpuRealtimePeriod=null, cpuRealtimeRuntime=null, cpuShares=null, cpuQuota=null, cpusetCpus=null, cpusetMems=null, devices=null, deviceCgroupRules=null, deviceRequests=null, diskQuota=null, dns=null, dnsOptions=null, dnsSearch=null, extraHosts=null, groupAdd=null, ipcMode=null, cgroup=null, links=[], logConfig=LogConfig(type=null, config=null), lxcConf=null, memory=null, memorySwap=null, memoryReservation=null, kernelMemory=null, networkMode=null, oomKillDisable=null, init=null, autoRemove=null, oomScoreAdj=null, portBindings=null, privileged=null, publishAllPorts=null, readonlyRootfs=null, restartPolicy=null, ulimits=null, cpuCount=null, cpuPercent=null, ioMaximumIOps=null, ioMaximumBandwidth=null, volumesFrom=null, mounts=null, pidMode=null, isolation=null, securityOpts=null, storageOpt=null, cgroupParent=null, volumeDriver=null, shmSize=null, pidsLimit=null, runtime=null, tmpFs=null, utSMode=null, usernsMode=null, sysctls=null, consoleSize=null, cgroupnsMode=null),hostName=,image=busybox:latest,ipv4Address=,ipv6Address=,labels=,macAddress=,name=,networkDisabled=,networkingConfig=,onBuild=,platform=,portSpecs=,shell=,stdInOnce=,stdinOpen=,stopSignal=,stopTimeout=,tty=,user=,volumes=Volumes(volumes=[]),workingDir=]
12:32:39.429 INFO c.g.d.cmd.CreateContainerCmdIT - Created container CreateContainerResponse(id=6e67168a6d32b9e98feb7ddd07f2d1e2a576e1498ecbdd77c395ee96c50ac39e, warnings=[])

but container is not created with annotations on the host config therefore inspect response return annotations as null:

14:24:00.202 INFO c.g.d.cmd.CreateContainerCmdIT - Container inspection response: InspectContainerResponse(args=[9999], config=ContainerConfig(attachStderr=false, attachStdin=false, attachStdout=false, cmd=[sleep, 9999], domainName=, entrypoint=null, env=[PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin], exposedPorts=null, hostName=8ace52143836, image=busybox:latest, labels={}, macAddress=null, networkDisabled=null, onBuild=null, stdinOpen=false, portSpecs=null, stdInOnce=false, tty=false, user=, volumes=null, workingDir=, healthCheck=null), created=2025-05-13T14:24:00.187078736Z, driver=overlay2, execDriver=null, hostConfig=HostConfig(binds=[], blkioWeight=0, blkioWeightDevice=null, blkioDeviceReadBps=null, blkioDeviceWriteBps=null, blkioDeviceReadIOps=null, blkioDeviceWriteIOps=null, memorySwappiness=null, nanoCPUs=0, annotations=null, capAdd=null, capDrop=null, containerIDFile=, cpuPeriod=0, cpuRealtimePeriod=0, cpuRealtimeRuntime=0, cpuShares=0, cpuQuota=0, cpusetCpus=, cpusetMems=, dev
14:24:00.203 INFO c.g.d.cmd.CreateContainerCmdIT - HostConfig from inspection: HostConfig(binds=[], blkioWeight=0, blkioWeightDevice=null, blkioDeviceReadBps=null, blkioDeviceWriteBps=null, blkioDeviceReadIOps=null, blkioDeviceWriteIOps=null, memorySwappiness=null, nanoCPUs=0, annotations=null, capAdd=null, capDrop=null, containerIDFile=, cpuPeriod=0, cpuRealtimePeriod=0, cpuRealtimeRuntime=0, cpuShares=0, cpuQuota=0, cpusetCpus=, cpusetMems=, devices=null, deviceCgroupRules=null, deviceRequests=null, diskQuota=null, dns=null, dnsOptions=null, dnsSearch=null, extraHosts=null, groupAdd=null, ipcMode=shareable, cgroup=, links=[], logConfig=LogConfig(type=json-file, config={}), lxcConf=null, memory=0, memorySwap=0, memoryReservation=0, kernelMemory=null, networkMode=bridge, oomKillDisable=false, init=null, autoRemove=false, oomScoreAdj=0, portBindings=null, privileged=false, publishAllPorts=false, readonlyRootfs=false, restartPolicy=no, ulimits=null, cpuCount=0, cpuPercent=0, ioMaximumIOps=0, ioMaximumBandwidth

@eddumelendez
Copy link
Member

looks like annotations are set building images not containers. See https://docs.docker.com/build/metadata/annotations/

So, I think we can close this one

@emirhandurmus
Copy link
Contributor Author

nope annotation are also added to hostconfig since api version 1.43.
https://docs.docker.com/reference/api/engine/version/v1.49/#tag/Container/operation/ContainerCreate
https://docs.docker.com/reference/api/engine/version/v1.49/#tag/Container/operation/ContainerInspect

curl -X POST
--unix-socket /var/run/docker.sock
"http://localhost/containers/create?name=test-annotations"
-H "Content-Type: application/json"
-d '{
"Image": "busybox",
"Cmd": ["sleep", "9999"],
"HostConfig": {
"Annotations": {
"com.example.key1": "value1"
}
}
}'
{"Id":"693e772829ff066df94bb91e292e75460b71f7214b2a5d86e8d6fc0b57317a79","Warnings":[]}

curl -X GET
--unix-socket /var/run/docker.sock
"http://localhost/containers/test-annotations/json"
{"Id":"13aff107b0c0053594906a8ef35c5bb825260e85f9ef017f0385bf91faddac6b","Created":"2025-05-13T16:28:15.495295845Z","Path":"sleep","Args":["9999"],"State":{"Status":"created","Running":false,"Paused":false,"Restarting":false,"OOMKilled":false,"Dead":false,"Pid":0,"ExitCode":0,"Error":"","StartedAt":"0001-01-01T00:00:00Z","FinishedAt":"0001-01-01T00:00:00Z"},"Image":"sha256:37f7b378a29ceb4c551b1b5582e27747b855bbfaa73fa11914fe0df028dc581f","ResolvConfPath":"","HostnamePath":"","HostsPath":"","LogPath":"","Name":"/test-annotations","RestartCount":0,"Driver":"overlayfs","Platform":"linux","MountLabel":"","ProcessLabel":"","AppArmorProfile":"","ExecIDs":null,"HostConfig":{"Binds":null,"ContainerIDFile":"","LogConfig":{"Type":"json-file","Config":{}},"NetworkMode":"bridge","PortBindings":{},"RestartPolicy":{"Name":"no","MaximumRetryCount":0},"AutoRemove":false,"VolumeDriver":"","VolumesFrom":null,"ConsoleSize":[0,0],"Annotations":{"com.example.key1":"value1"},"CapAdd":null,"CapDrop":null,"CgroupnsMode":"private","Dns":null,"DnsOptions":null,"DnsSearch":null,"ExtraHosts":null,"GroupAdd":null,"IpcMode":"private","Cgroup":"","Links":null,"OomScoreAdj":0,"PidMode":"","Privileged":false,"PublishAllPorts":false,"ReadonlyRootfs":false,"SecurityOpt":null,"UTSMode":"","UsernsMode":"","ShmSize":67108864,"Runtime":"runc","Isolation":"","CpuShares":0,"Memory":0,"NanoCpus":0,"CgroupParent":"","BlkioWeight":0,"BlkioWeightDevice":null,"BlkioDeviceReadBps":null,"BlkioDeviceWriteBps":null,"BlkioDeviceReadIOps":null,"BlkioDeviceWriteIOps":null,"CpuPeriod":0,"CpuQuota":0,"CpuRealtimePeriod":0,"CpuRealtimeRuntime":0,"CpusetCpus":"","CpusetMems":"","Devices":null,"DeviceCgroupRules":null,"DeviceRequests":null,"MemoryReservation":0,"MemorySwap":0,"MemorySwappiness":null,"OomKillDisable":false,"PidsLimit":null,"Ulimits":null,"CpuCount":0,"CpuPercent":0,"IOMaximumIOps":0,"IOMaximumBandwidth":0,"MaskedPaths":["/proc/asound","/proc/acpi","/proc/kcore","/proc/keys","/proc/latency_stats","/proc/timer_list","/proc/timer_stats","/proc/sched_debug","/proc/scsi","/sys/firmware","/sys/devices/virtual/powercap"],"ReadonlyPaths":["/proc/bus","/proc/fs","/proc/irq","/proc/sys","/proc/sysrq-trigger"]},"GraphDriver":{"Data":null,"Name":"overlayfs"},"Mounts":[],"Config":{"Hostname":"13aff107b0c0","Domainname":"","User":"","AttachStdin":false,"AttachStdout":false,"AttachStderr":false,"Tty":false,"OpenStdin":false,"StdinOnce":false,"Env":["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"],"Cmd":["sleep","9999"],"Image":"busybox","Volumes":null,"WorkingDir":"","Entrypoint":null,"OnBuild":null,"Labels":{}},"NetworkSettings":{"Bridge":"","SandboxID":"","SandboxKey":"","Ports":{},"HairpinMode":false,"LinkLocalIPv6Address":"","LinkLocalIPv6PrefixLen":0,"SecondaryIPAddresses":null,"SecondaryIPv6Addresses":null,"EndpointID":"","Gateway":"","GlobalIPv6Address":"","GlobalIPv6PrefixLen":0,"IPAddress":"","IPPrefixLen":0,"IPv6Gateway":"","MacAddress":"","Networks":{"bridge":{"IPAMConfig":null,"Links":null,"Aliases":null,"MacAddress":"","DriverOpts":null,"GwPriority":0,"NetworkID":"","EndpointID":"","Gateway":"","IPAddress":"","IPPrefixLen":0,"IPv6Gateway":"","GlobalIPv6Address":"","GlobalIPv6PrefixLen":0,"DNSNames":null}}},"ImageManifestDescriptor":{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"sha256:fa8dc70514f29471fe118446e3f84040b19791531ec197836a4f43baf13d744b","size":610,"annotations":{"com.docker.official-images.bashbrew.arch":"arm64v8","org.opencontainers.image.base.name":"scratch","org.opencontainers.image.created":"2025-03-18T16:21:15Z","org.opencontainers.image.revision":"498afd94774b792e7048ee644f310b2df83e9777","org.opencontainers.image.source":"https://github.com/docker-library/busybox.git","org.opencontainers.image.url":"https://hub.docker.com/_/busybox","org.opencontainers.image.version":"1.37.0-glibc"},"platform":{"architecture":"arm64","os":"linux","variant":"v8"}}}

@emirhandurmus
Copy link
Contributor Author

@eddumelendez I just realized that the reason test was failed is due to default client for test use older api version. I fixed the test case.

here is my local test results.
19:48:41.307 DEBUG c.g.d.core.command.AbstrDockerCmd - Cmd: com.github.dockerjava.core.command.CreateContainerCmdImpl@5454d35e[aliases=,argsEscaped=,attachStderr=,attachStdin=,attachStdout=,authConfig=AuthConfig(username=null, email=null, registryAddress=https://index.docker.io/v1/, stackOrchestrator=null),cmd=,domainName=,entrypoint=,env={REGISTRY_AUTH=htpasswd,REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm,REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd,REGISTRY_LOG_LEVEL=debug,REGISTRY_HTTP_TLS_CERTIFICATE=/certs/domain.crt,REGISTRY_HTTP_TLS_KEY=/certs/domain.key},exposedPorts=ExposedPorts(exposedPorts=[]),healthcheck=,hostConfig=HostConfig(binds=[], blkioWeight=null, blkioWeightDevice=null, blkioDeviceReadBps=null, blkioDeviceWriteBps=null, blkioDeviceReadIOps=null, blkioDeviceWriteIOps=null, memorySwappiness=null, nanoCPUs=null, annotations=null, capAdd=null, capDrop=null, containerIDFile=null, cpuPeriod=null, cpuRealtimePeriod=null, cpuRealtimeRuntime=null, cpuShares=null, cpuQuota=null, cpusetCpus=null, cpusetMems=null, devices=null, deviceCgroupRules=null, deviceRequests=null, diskQuota=null, dns=null, dnsOptions=null, dnsSearch=null, extraHosts=null, groupAdd=null, ipcMode=null, cgroup=null, links=[], logConfig=LogConfig(type=null, config=null), lxcConf=null, memory=null, memorySwap=null, memoryReservation=null, kernelMemory=null, networkMode=null, oomKillDisable=null, init=null, autoRemove=null, oomScoreAdj=null, portBindings={5000/tcp=[Lcom.github.dockerjava.api.model.Ports$Binding;@8e50104}, privileged=null, publishAllPorts=null, readonlyRootfs=null, restartPolicy=null, ulimits=null, cpuCount=null, cpuPercent=null, ioMaximumIOps=null, ioMaximumBandwidth=null, volumesFrom=null, mounts=null, pidMode=null, isolation=null, securityOpts=null, storageOpt=null, cgroupParent=null, volumeDriver=null, shmSize=null, pidsLimit=null, runtime=null, tmpFs=null, utSMode=null, usernsMode=null, sysctls=null, consoleSize=null, cgroupnsMode=null),hostName=,image=private-registry-image:2,ipv4Address=,ipv6Address=,labels=,macAddress=,name=,networkDisabled=,networkingConfig=,onBuild=,platform=,portSpecs=,shell=,stdInOnce=,stdinOpen=,stopSignal=,stopTimeout=,tty=,user=,volumes=Volumes(volumes=[]),workingDir=]
19:48:41.541 DEBUG c.g.d.core.command.AbstrDockerCmd - Cmd: 6774241b963bb9b43f04982930dbe60958e1ca6efcd56336ffd0dc3b43146296
19:48:44.738 DEBUG c.github.dockerjava.core.DockerRule - Connecting to Docker server
19:48:44.746 DEBUG c.g.d.core.command.AbstrDockerCmd - Cmd: busybox:latest
19:48:44.946 DEBUG c.g.d.core.command.AbstrDockerCmd - Cmd: com.github.dockerjava.core.command.CreateContainerCmdImpl@6c2c1385[aliases=,argsEscaped=,attachStderr=,attachStdin=,attachStdout=,authConfig=AuthConfig(username=null, email=null, registryAddress=https://index.docker.io/v1/, stackOrchestrator=null),cmd={sleep,9999},domainName=,entrypoint=,env=,exposedPorts=ExposedPorts(exposedPorts=[]),healthcheck=,hostConfig=HostConfig(binds=[], blkioWeight=null, blkioWeightDevice=null, blkioDeviceReadBps=null, blkioDeviceWriteBps=null, blkioDeviceReadIOps=null, blkioDeviceWriteIOps=null, memorySwappiness=null, nanoCPUs=null, annotations={com.example.key2=value2, com.example.key1=value1}, capAdd=null, capDrop=null, containerIDFile=null, cpuPeriod=null, cpuRealtimePeriod=null, cpuRealtimeRuntime=null, cpuShares=null, cpuQuota=null, cpusetCpus=null, cpusetMems=null, devices=null, deviceCgroupRules=null, deviceRequests=null, diskQuota=null, dns=null, dnsOptions=null, dnsSearch=null, extraHosts=null, groupAdd=null, ipcMode=null, cgroup=null, links=[], logConfig=LogConfig(type=null, config=null), lxcConf=null, memory=null, memorySwap=null, memoryReservation=null, kernelMemory=null, networkMode=null, oomKillDisable=null, init=null, autoRemove=null, oomScoreAdj=null, portBindings=null, privileged=null, publishAllPorts=null, readonlyRootfs=null, restartPolicy=null, ulimits=null, cpuCount=null, cpuPercent=null, ioMaximumIOps=null, ioMaximumBandwidth=null, volumesFrom=null, mounts=null, pidMode=null, isolation=null, securityOpts=null, storageOpt=null, cgroupParent=null, volumeDriver=null, shmSize=null, pidsLimit=null, runtime=null, tmpFs=null, utSMode=null, usernsMode=null, sysctls=null, consoleSize=null, cgroupnsMode=null),hostName=,image=busybox:latest,ipv4Address=,ipv6Address=,labels=,macAddress=,name=,networkDisabled=,networkingConfig=,onBuild=,platform=,portSpecs=,shell=,stdInOnce=,stdinOpen=,stopSignal=,stopTimeout=,tty=,user=,volumes=Volumes(volumes=[]),workingDir=]
19:48:45.082 INFO c.g.d.cmd.CreateContainerCmdIT - Created container CreateContainerResponse(id=7dcbdcf165ba3663ac84afec0b701aa1076cfde43d204ce49c537aab30d069f3, warnings=[])
19:48:45.087 DEBUG c.g.d.core.command.AbstrDockerCmd - Cmd: 7dcbdcf165ba3663ac84afec0b701aa1076cfde43d204ce49c537aab30d069f3,false
19:48:45.089 DEBUG c.g.d.c.exec.InspectContainerCmdExec - GET: DefaultWebTarget{path=[/containers/7dcbdcf165ba3663ac84afec0b701aa1076cfde43d204ce49c537aab30d069f3/json], queryParams={}}
19:48:45.479 DEBUG c.g.d.core.command.AbstrDockerCmd - Cmd: 6774241b963bb9b43f04982930dbe60958e1ca6efcd56336ffd0dc3b43146296,true,true

@eddumelendez eddumelendez added this to the next milestone Jul 4, 2025
@eddumelendez eddumelendez merged commit 9ccbd8f into docker-java:main Jul 4, 2025
4 checks passed
@eddumelendez
Copy link
Member

Thanks for you contribution, @emirhandurmus !

svc-squareup-copybara pushed a commit to cashapp/misk that referenced this pull request Jul 8, 2025
| Package | Type | Package file | Manager | Update | Change |
|---|---|---|---|---|---|
|
[com.github.docker-java:docker-java-transport-httpclient5](https://github.com/docker-java/docker-java)
| dependencies | misk/gradle/libs.versions.toml | gradle | patch |
`3.5.2` -> `3.5.3` |
|
[com.github.docker-java:docker-java-transport](https://github.com/docker-java/docker-java)
| dependencies | misk/gradle/libs.versions.toml | gradle | patch |
`3.5.2` -> `3.5.3` |
|
[com.github.docker-java:docker-java-core](https://github.com/docker-java/docker-java)
| dependencies | misk/gradle/libs.versions.toml | gradle | patch |
`3.5.2` -> `3.5.3` |
|
[com.github.docker-java:docker-java-api](https://github.com/docker-java/docker-java)
| dependencies | misk/gradle/libs.versions.toml | gradle | patch |
`3.5.2` -> `3.5.3` |
|
[com.github.docker-java:docker-java](https://github.com/docker-java/docker-java)
| dependencies | misk/gradle/libs.versions.toml | gradle | patch |
`3.5.2` -> `3.5.3` |

---

### Release Notes

<details>
<summary>docker-java/docker-java
(com.github.docker-java:docker-java-transport-httpclient5)</summary>

###
[`v3.5.3`](https://github.com/docker-java/docker-java/releases/tag/3.5.3)

[Compare
Source](docker-java/docker-java@3.5.2...3.5.3)

##### Changes

- Bump jackson.version from 2.18.3 to 2.18.4
[@&#8203;dependabot](https://github.com/dependabot)
([#&#8203;2473](docker-java/docker-java#2473))
- Drop jackson-jaxrs-json-provider dependency
[@&#8203;eddumelendez](https://github.com/eddumelendez)
([#&#8203;2468](docker-java/docker-java#2468))
- Bump org.testcontainers:testcontainers from 1.21.2 to 1.21.3
[@&#8203;dependabot](https://github.com/dependabot)
([#&#8203;2467](docker-java/docker-java#2467))
- Bump commons-io:commons-io from 2.18.0 to 2.19.0
[@&#8203;dependabot](https://github.com/dependabot)
([#&#8203;2428](docker-java/docker-java#2428))
- Bump netty.version from 4.1.119.Final to 4.2.2.Final
[@&#8203;dependabot](https://github.com/dependabot)
([#&#8203;2454](docker-java/docker-java#2454))
- Bump org.apache.httpcomponents.client5:httpclient5 from 5.4.4 to 5.5
[@&#8203;dependabot](https://github.com/dependabot)
([#&#8203;2445](docker-java/docker-java#2445))

##### 📈 Enhancements

- Annotations option added to hostconfig
[@&#8203;emirhandurmus](https://github.com/emirhandurmus)
([#&#8203;2422](docker-java/docker-java#2422))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "after 6pm every weekday,before 2am
every weekday" in timezone Australia/Melbourne, Automerge - At any time
(no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Never, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about these
updates again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Renovate
Bot](https://github.com/renovatebot/renovate).

GitOrigin-RevId: a6ed07fba1bfcc1f48eed708427db745d4823318
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants