Skip to content

workaround for docker not found error #435

@jillesvangurp

Description

@jillesvangurp

I think there's something wonky with how the docker command is resolved. I commented about a simple workaround a few weeks ago on this on one of the closed tickets: #406 (comment)

But after fixing this again on another project, I think it would be nice to just integrate the fix in the plugin or at least document the workaround somewhere.

In short, on Java 21 (with sdkman), docker for desktop, and mac the plugin is no longer able to resolve the docker command from gradle.

Here's the work around:

listOf("/usr/bin/docker","/usr/local/bin/docker").firstOrNull { 
    File(it).exists()
}?.let { docker ->
    // works around an issue where the docker 
    // command is not found
    // falls back to the default, which may work on
    // some platforms
    dockerExecutable.set(docker)
} 

What this does is it tries to lookup the docker command in a few standard locations where it would normally be found before falling back to the existing behavior of trying to do magic via the PATH variable. Somehow it skips /usr/local/bin/docker, which is where I definitely have it and which is definitely on my PATH. It worked in Java 17 and somehow after switching to Java 21 (via sdkman, this may be a factor) it doesn't.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions