Skip to content

Improve logging in DockerApi #43460

Closed as not planned
Closed as not planned
@PierrickPuimeanChieze

Description

@PierrickPuimeanChieze

I got a problem when trying to use the gradle buildBootImage task. I managed to track the source of the problem and it was a problem with my installation of docker which refused to allow a _ping.
But the symptom was not really clear as I only got the following message : Docker API version must be at least 1.41 to support the 'imagePlatform' option, but current API version is 1.24
I think this could be a good idea to add a log message when you get an exception when trying to ping the docker installation.
But after looking at DockerAPI and SystemAPI classes, I don't really know which form it could take :

	class SystemApi {

		SystemApi() {
		}

		/**
		 * Get the API version supported by the Docker daemon.
		 * @return the Docker daemon API version
		 */
		ApiVersion getApiVersion() {
			try {
				URI uri = new URIBuilder("/_ping").build();
				try (Response response = http().head(uri)) {
					Header apiVersionHeader = response.getHeader(API_VERSION_HEADER_NAME);
					if (apiVersionHeader != null) {
						return ApiVersion.parse(apiVersionHeader.getValue());
					}
				}
				catch (Exception ex) {
					// fall through to return default value
                                        // Add a way to log the exception here ?
				}
				return MINIMUM_API_VERSION;
			}
			catch (URISyntaxException ex) {
				throw new IllegalStateException(ex);
			}
		}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: supersededAn issue that has been superseded by another

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions