Skip to content

Shouldn't mount.destination be a string instead of a 'Volume' object ? #1046

Description

@jeanfabrice

According to docker API (>1.20), a container mount volume has a 'destination' property with type: string (see https://docs.docker.com/engine/api/v1.20/#inspect-a-container and later api spec)

In docker-java, the 'destination' property is not a string (why ?) but a 'Volume' object (having a 'path' property). See : https://github.com/docker-java/docker-java/blob/master/src/main/java/com/github/dockerjava/api/command/InspectContainerResponse.java#L454

This seems to prevent docker-build-step-plugin Jenkins plugin, which makes a heavy use of docker-java, to successfully creates a container with bind mounts attached (and works like a charm without bind mounts). At some point, this jenkins plugin tries to compare the Docker json response of the new container to the docker-java json corresponding object (https://github.com/jenkinsci/docker-build-step-plugin/blob/master/src/main/java/org/jenkinsci/plugins/dockerbuildstep/cmd/CreateContainerCommand.java#L217) then raised a java.lang.IllegalArgumentException.

This is probably a duplicate of #1015.

Here is the stack trace :

com.fasterxml.jackson.databind.JsonMappingException: No suitable constructor found for type [simple type, class com.github.dockerjava.api.model.Volume]: can not instantiate from JSON object (missing default constructor or creator, or perhaps need to add/enable type information?)
 at [Source: {"Args":["eswrapper"],"Config":{"AttachStderr":false,"AttachStdin":false,"AttachStdout":false,"Cmd":["eswrapper"],"Domainname":"","Entrypoint":["/usr/local/bin/docker-entrypoint.sh"],"Env":["PATH=/usr/share/elasticsearch/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin","ELASTIC_CONTAINER=true","JAVA_HOME=/usr/lib/jvm/jre-1.8.0-openjdk"],"ExposedPorts":{"9200/tcp":{},"9300/tcp":{}},"Hostname":"ELASTICSEARCH","Image":"docker.elastic.co/elasticsearch/elasticsearch-oss:6.2.4","Labels":{"maintainer":"Elastic Docker Team <docker@elastic.co>","org.label-schema.schema-version":"= 1.0     org.label-schema.name=CentOS Base Image     org.label-schema.vendor=CentOS     org.label-schema.license=GPLv2     org.label-schema.build-date=20180402"},"OpenStdin":false,"StdinOnce":false,"Tty":false,"User":"","WorkingDir":"/usr/share/elasticsearch"},"Created":"2018-05-25T23:53:44.963270132Z","Driver":"aufs","ExecDriver":null,"HostConfig":{"Binds":["/tmp:/tmp:rw"],"BlkioWeight":0,"ContainerIDFile":"","CpuPeriod":0,"CpuShares":0,"CpuQuota":0,"CpusetCpus":"","CpusetMems":"","LogConfig":{"Type":"json-file","Config":{}},"Memory":0,"MemorySwap":0,"MemoryReservation":0,"KernelMemory":0,"NetworkMode":"default","OomKillDisable":false,"OomScoreAdj":false,"Privileged":false,"PublishAllPorts":false,"ReadonlyRootfs":false,"RestartPolicy":{"MaximumRetryCount":0,"Name":""},"PidMode":"","CgroupParent":"","VolumeDriver":"","ShmSize":67108864,"PidsLimit":0},"HostnamePath":"","HostsPath":"","LogPath":"","Id":"de2ecce94f41b3b9871f51bc80da00be8f8dfa9a01da119431ef5140885903f2","SizeRootFs":null,"Image":"sha256:3822ba554fe95f9ef68baa75cae97974135eb6aa8f8f37cadf11f6a59bde0139","MountLabel":"","Name":"/elasticsearch_zBfN00sDOGF2","RestartCount":0,"NetworkSettings":{"Bridge":"","SandboxID":"","HairpinMode":false,"LinkLocalIPv6Address":"","LinkLocalIPv6PrefixLen":0,"Ports":{},"SandboxKey":"","SecondaryIPAddresses":null,"SecondaryIPv6Addresses":null,"EndpointID":"","Gateway":"","PortMapping":null,"GlobalIPv6Address":"","GlobalIPv6PrefixLen":0,"IPAddress":"","IPPrefixLen":0,"IPv6Gateway":"","MacAddress":"","Networks":{"bridge":{"IPAMConfig":null,"Links":null,"Aliases":null,"NetworkID":"","EndpointID":"","Gateway":"","IPAddress":"","IPPrefixLen":0,"IPv6Gateway":"","GlobalIPv6Address":"","GlobalIPv6PrefixLen":0,"MacAddress":""}}},"Path":"/usr/local/bin/docker-entrypoint.sh","ProcessLabel":"","ResolvConfPath":"","ExecIDs":null,"State":{"oomkilled":false,"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","Health":null},"Volumes":null,"VolumesRW":null,"Mounts":[{"Name":null,"Source":"/tmp","Destination":{"path":"/tmp"},"Driver":null,"Mode":"rw","RW":true}]}; line: 1, column: 2765] (through reference chain: com.github.dockerjava.api.command.InspectContainerResponse["Mounts"]->java.util.ArrayList[0]->com.github.dockerjava.api.command.Mount["Destination"])
	at com.fasterxml.jackson.databind.JsonMappingException.from(JsonMappingException.java:148)
	at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeFromObjectUsingNonDefault(BeanDeserializerBase.java:1106)
	at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:296)
	at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:133)
	at com.fasterxml.jackson.databind.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:520)
	at com.fasterxml.jackson.databind.deser.impl.FieldProperty.deserializeAndSet(FieldProperty.java:101)
	at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:258)
	at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:125)
	at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:245)
	at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:217)
	at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:25)
	at com.fasterxml.jackson.databind.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:520)
	at com.fasterxml.jackson.databind.deser.impl.FieldProperty.deserializeAndSet(FieldProperty.java:101)
	at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:258)
	at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:125)
	at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3736)
	at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2726)
	at org.jenkinsci.plugins.dockerbuildstep.cmd.CreateContainerCommand.execute(CreateContainerCommand.java:217)
Caused: java.lang.IllegalArgumentException
	at org.jenkinsci.plugins.dockerbuildstep.cmd.CreateContainerCommand.execute(CreateContainerCommand.java:225)
	at org.jenkinsci.plugins.dockerbuildstep.DockerBuilder.perform(DockerBuilder.java:77)
	at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
	at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:744)
	at hudson.model.Build$BuildExecution.build(Build.java:206)
	at hudson.model.Build$BuildExecution.doRun(Build.java:163)
	at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:504)
	at hudson.model.Run.execute(Run.java:1727)
	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
	at hudson.model.ResourceController.execute(ResourceController.java:97)
	at hudson.model.Executor.run(Executor.java:429)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions