arquillian / arquillian-cube

Control (docker, kubernetes, openshift) containers in your tests with ease!
http://arquillian.org/arquillian-cube/
120 stars 98 forks source link

DockerClientException: Could not build image: null when building from dockerfile #829

Closed mbrasier closed 6 years ago

mbrasier commented 6 years ago
Issue Overview

When building a docker image from a dockerfile, a DockerClientException: Could not build image: null is thrown, this appears to be caused by using an old version of docker-java, as it is a fixed bug in the latest versions.

Expected Behaviour

No exception is thrown

Current Behaviour
Caused by: com.github.dockerjava.api.exception.DockerClientException: Could not build image: null
    at com.github.dockerjava.core.command.BuildImageResultCallback.getImageId(BuildImageResultCallback.java:71)
    at com.github.dockerjava.core.command.BuildImageResultCallback.awaitImageId(BuildImageResultCallback.java:48)
    at org.arquillian.cube.docker.impl.docker.DockerClientExecutor.buildImage(DockerClientExecutor.java:738)
Steps To Reproduce

Use a dockerfile to build an image:

        <property name="dockerContainers">
            unit-test:
                buildImage:
                    dockerfileLocation: src/test/docker/unit-test
                    noCache: true
                    remove: true
                await:
                    strategy: sleeping
                    sleepTime: 30 s
                portBindings: [1090->1080/tcp, 9999/tcp, 8080/tcp]
                restartPolicy:
                    name: failure
                    maximumRetryCount: 1
                manual: false
Additional Information

See https://github.com/docker-java/docker-java/issues/860 for related docker-java issue

lordofthejars commented 6 years ago

Can you provide a github project so we can take a look?

mbrasier commented 6 years ago

I will put something together next week.

lordofthejars commented 6 years ago

Great, thank you very much, since I am not sure what is happening because we have tested this use case as well (or at least with the description) then I am not sure what is happening. Then with an example I will be able to debug, fix it in cube or provide you a solution on your example

mbrasier commented 6 years ago

It seems to be an issue with the latest version of docker, which doesn't work with the older version of docker-java that arquillian-cube (at least the version in the latest arquillian-universe BOM) uses. Tracing through, docker outputs a string "Successfully tagged" when the image is created, but docker-java is looking for the string "Successfully created" and so assumes that creation of the container failed. It may be you start seeing the issue if you updated to the latest docker release.

lordofthejars commented 6 years ago

Then assuming that latest docker-java has fixed, you can update the version on your pom and try it.

mbrasier commented 6 years ago

Yes that works, but this ticket is to ensure that arquillian-cube updates its dependency (having a dependency on docker-java in our project isn't great, because we don't depend on it, other than to fix arquillian-cube).

lordofthejars commented 6 years ago

ok, then it is easy, thanks:) I'll do it now.