Skip to content
This repository has been archived by the owner on Mar 31, 2022. It is now read-only.

Fix proposal for #112 : configuration of docker host #297

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
import java.util.Objects;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;

import org.apache.commons.lang3.StringUtils;
import org.apache.maven.archiver.MavenArchiveConfiguration;
import org.apache.maven.archiver.MavenArchiver;
import org.apache.maven.execution.MavenSession;
Expand Down Expand Up @@ -147,6 +149,13 @@ public String getFileName() {
@Parameter(property = "dockerfile.password")
protected String password;

/**
* URI used for executing docker commands. For example "http://localhost:2375"
* If this is set, the DOCKER_HOST environment variable will be ignored.
*/
@Parameter(property = "dockerfile.dockerHostUri")
protected String dockerHostUri;

/**
* Whether to output a verbose log when performing various operations.
*/
Expand Down Expand Up @@ -435,12 +444,15 @@ private DockerClient openDockerClient() throws MojoExecutionException {
final RegistryAuthSupplier authSupplier = createRegistryAuthSupplier();

try {
return DefaultDockerClient.fromEnv()
.readTimeoutMillis(readTimeoutMillis)
.connectTimeoutMillis(connectTimeoutMillis)
.registryAuthSupplier(authSupplier)
.useProxy(useProxy)
.build();
DefaultDockerClient.Builder builder = DefaultDockerClient.fromEnv();
if (StringUtils.isNotEmpty(dockerHostUri)) {
builder.uri(dockerHostUri);
}
return builder.readTimeoutMillis(readTimeoutMillis)
.connectTimeoutMillis(connectTimeoutMillis)
.registryAuthSupplier(authSupplier)
.useProxy(useProxy)
.build();
} catch (DockerCertificateException e) {
throw new MojoExecutionException("Could not load Docker certificates", e);
}
Expand Down