Skip to content

Commit

Permalink
SDK-339: Fix auto Docker setup in Sdk (#297)
Browse files Browse the repository at this point in the history
* docker-fix

* add windows pipe for connecting to docker on windows
  • Loading branch information
kb019 authored Oct 4, 2024
1 parent 7e10aaf commit 8bf2c07
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@
import com.github.dockerjava.api.model.PullResponseItem;
import com.github.dockerjava.api.model.Volume;
import org.apache.commons.lang.StringUtils;
import com.github.dockerjava.api.command.ListImagesCmd;
import org.apache.maven.plugin.MojoExecutionException;

import java.io.Closeable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Collections;
import java.util.concurrent.CountDownLatch;

/**
Expand Down Expand Up @@ -62,8 +64,10 @@ public void executeTask() throws MojoExecutionException {
}

private boolean noMySqlImage(DockerClient docker) {
List<Image> mysql = docker.listImagesCmd().withImageNameFilter(MYSQL_8_4_1).exec();
return mysql.size() == 0;
ListImagesCmd listImagesCmd = docker.listImagesCmd();
listImagesCmd.getFilters().put("reference", Collections.singletonList(MYSQL_8_4_1));
List<Image> mysql = listImagesCmd.exec();
return mysql.isEmpty();
}

private void createMysqlContainer(DockerClient docker) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -971,7 +971,7 @@ private String determineDefaultDockerHost() {

private String determineWindowsDockerHost() {
if (determineDockerForWindowsHost()) {
return DockerHelper.DEFAULT_HOST_DOCKER_FOR_WINDOWS;
return DockerHelper.DEFAULT_WINDOWS_PIPE_FOR_DOCKER;
} else {
return determineDockerToolboxHost();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public class DockerHelper {
private static final String DOCKER_HOST_KEY = "dockerHost";
public static final String DEFAULT_DOCKER_HOST_UNIX_SOCKET = "unix:///var/run/docker.sock";
public static final String DEFAULT_HOST_DOCKER_FOR_WINDOWS = "http://127.0.0.1:2375/";
public static final String DEFAULT_WINDOWS_PIPE_FOR_DOCKER = "npipe:////./pipe/docker_engine";

private static final String DOCKER_HOST_MSG_WINDOWS = "To use dockerized MySQL, You have to pass Docker Host URL to SDK. " +
"You should run SDK from docker-machine command line, so SDK can connect to your Docker. Your individual docker host URL can be obtained by calling command" +
Expand Down

0 comments on commit 8bf2c07

Please sign in to comment.