3

Hello I'm trying to build a Docker image from a Docker file and get the following error:

java.lang.IllegalStateException: Could not acquire image ID or digest following build at com.google.common.base.Preconditions.checkState(Preconditions.java:444) ~[guava-21.0.jar:na] at com.spotify.docker.client.DefaultDockerClient$BuildProgressHandler.getImageId(DefaultDockerClient.java:298) ~[docker-client-8.11.7.jar:8.11.7] at com.spotify.docker.client.DefaultDockerClient$BuildProgressHandler.access$1200(DefaultDockerClient.java:287) ~[docker-client-8.11.7.jar:8.11.7] at com.spotify.docker.client.DefaultDockerClient.build(DefaultDockerClient.java:1481) ~[docker-client-8.11.7.jar:8.11.7]

I can build the same exact Dockerfile from the command line, but I can't debug this as the stack trace isn't very informative. Below I leave some information that may be relevant:

Docker version:

Client: Version: 17.03.2-ce API version: 1.27 Server: Version: 17.03.2-ce API version: 1.27 (minimum version 1.12)

spotify/docker-client version: 8.11.7

How I call the docker build function:

final AtomicReference<String> imageIdFromMessage = new AtomicReference<>();

final String returnedImageId = dockerClient.build(

Paths.get("/absolute/path/to/folder"), image.getImageName(), dockerfilefilename,new ProgressHandler() {
    @Override
    public void progress(ProgressMessage message) throws DockerException {

        final String imageId = message.buildImageId();

        if (imageId != null) {
            imageIdFromMessage.set(imageId);
        }
    }
});

I can submit any other relevant info and would appreciate any help or ideas.

Edit to add requested info:

image is a personal data representation of a docker image, the only relevant thing about it is it has the name I want to tag the docker.

dockerfilefilename again is just a string that contains the filename of the dockerfile. For example, the string "Dockerfile".

dockerClient is an instance of DockerClient. It was created like this:

`

    DockerClient dc = DefaultDockerClient.fromEnv().build();
    final RegistryAuth registryAuth = RegistryAuth.builder() //TODO change to external config
            .email("REDACTED")
            .username("REDACTED")
            .password("REDACTED")
            .build();
    final int statusCode = dc.auth(registryAuth);

    return dc;

`

I have checked and the status code is in fact 200. I've tried many Docker commands with the driver which are successful.

PSilvestre
  • 61
  • 1
  • 3
  • 2
    where are `dockerClient`, `image`, and `dockerfilefilename` declared, and what are they – scigs Aug 16 '18 at 15:48
  • I edited the page to include the requested information. – PSilvestre Aug 17 '18 at 13:47
  • Any chance that you fixed or worked around the problem? I've encountered the same issue yesterday and up till now have no clue why is it happening :( – Paweł Motyl Sep 15 '18 at 15:38
  • I got the same message from maven plugin and I was able to solve it by removing `.dockerignore` file: https://github.com/spotify/dockerfile-maven/issues/25#issuecomment-310667051 – Slava Semushin Oct 04 '18 at 22:42

3 Answers3

2

I have encountered the same problem (as I've stated in comment to the question) and managed to fix it. The error that you get is a generic one and results from a failed sanity check inside the Docker client code that can be caused by a myriad of different things.

To get the specific reason that caused the sanity check fail you can look into message.error() in the progress handler - in my case the error message that was there was very clear.

Paweł Motyl
  • 1,304
  • 10
  • 16
1

I had the following problem at my end. In my dockerfile, the maintainer was mis-spelled. Please debug by trying to build the image using docker build -t .

Cshah
  • 5,612
  • 10
  • 33
  • 37
0

In the Dockerfile, had added an environment variable but missed ENV.

Correct: ENV KEYCLOAK_ADMIN=keycloak

Bad: KEYCLOAK_ADMIN=keycloak

alturium
  • 548
  • 5
  • 15