Refine search
public static Builder createDefaultConfigBuilder() { return createDefaultConfigBuilder(System.getenv(), (Properties) System.getProperties().clone()); }
public DefaultDockerClientConfig build() { SSLConfig sslConfig = null; if (customSslConfig == null) { if (isTrue(dockerTlsVerify)) { dockerCertPath = checkDockerCertPath(dockerCertPath); sslConfig = new LocalDirectorySSLConfig(dockerCertPath); } } else { sslConfig = customSslConfig; } return new DefaultDockerClientConfig(dockerHost, dockerConfig, apiVersion, registryUrl, registryUsername, registryPassword, registryEmail, sslConfig); }
DefaultDockerClientConfig(URI dockerHost, String dockerConfigPath, String apiVersion, String registryUrl, String registryUsername, String registryPassword, String registryEmail, SSLConfig sslConfig) { this.dockerHost = checkDockerHostScheme(dockerHost); this.dockerConfigPath = dockerConfigPath; this.apiVersion = RemoteApiVersion.parseConfigWithDefault(apiVersion); this.sslConfig = sslConfig; this.registryUsername = registryUsername; this.registryPassword = registryPassword; this.registryEmail = registryEmail; this.registryUrl = registryUrl; }
return new Container(containerResponse, getMappedPorts(ports), getHost(clientConfig.getDockerHost()), client);
private static void setAuthFromFile(final PullImageCmd pullImageCmd, final DefaultDockerClientConfig dockerClientConfig, final String imageName) { final AuthConfig authConfig = dockerClientConfig.effectiveAuthConfig(imageName); if (authConfig != null) { pullImageCmd.withAuthConfig(authConfig); } }
public EnvironmentAndSystemPropertyClientProviderStrategy() { // Try using environment variables config = DefaultDockerClientConfig.createDefaultConfigBuilder().build(); }
DefaultDockerClientConfig(URI dockerHost, String dockerConfigPath, String apiVersion, String registryUrl, String registryUsername, String registryPassword, String registryEmail, SSLConfig sslConfig) { this.dockerHost = checkDockerHostScheme(dockerHost); this.dockerConfigPath = dockerConfigPath; this.apiVersion = RemoteApiVersion.parseConfigWithDefault(apiVersion); this.sslConfig = sslConfig; this.registryUsername = registryUsername; this.registryPassword = registryPassword; this.registryEmail = registryEmail; this.registryUrl = registryUrl; }
public DefaultDockerClientConfig build() { SSLConfig sslConfig = null; if (customSslConfig == null) { if (isTrue(dockerTlsVerify)) { dockerCertPath = checkDockerCertPath(dockerCertPath); sslConfig = new LocalDirectorySSLConfig(dockerCertPath); } } else { sslConfig = customSslConfig; } return new DefaultDockerClientConfig(dockerHost, dockerConfig, apiVersion, registryUrl, registryUsername, registryPassword, registryEmail, sslConfig); }
private DockerClientImpl() { this(DefaultDockerClientConfig.createDefaultConfigBuilder().build()); }
private static DockerClientConfig configWithServerUrl(String serverUrl) { return DefaultDockerClientConfig.createDefaultConfigBuilder().withDockerHost(serverUrl).build(); }
@NotNull protected DockerClientConfig tryConfiguration(String dockerHost) { config = DefaultDockerClientConfig.createDefaultConfigBuilder() .withDockerHost(dockerHost) .withDockerTlsVerify(false) .build(); client = getClientForConfig(config); final int timeout = Integer.getInteger(PING_TIMEOUT_PROPERTY_NAME, PING_TIMEOUT_DEFAULT); ping(client, timeout); return config; } }
@NotNull private DockerClientConfig tryConfiguration() { URI dockerHost = URI.create(SOCKET_LOCATION); config = new DelegatingDockerClientConfig( DefaultDockerClientConfig.createDefaultConfigBuilder() .withDockerHost("tcp://localhost:0") .withDockerTlsVerify(false) .build() ) { @Override public URI getDockerHost() { return dockerHost; } }; client = getClientForConfig(config); final int timeout = Integer.parseInt(System.getProperty(PING_TIMEOUT_PROPERTY_NAME, PING_TIMEOUT_DEFAULT)); ping(client, timeout); return config; }
@Override public void test() throws InvalidConfigurationException { try { boolean installed = DockerMachineClient.instance().isInstalled(); checkArgument(installed, "docker-machine executable was not found on PATH (" + Arrays.toString(CommandLine.getSystemPath()) + ")"); Optional<String> machineNameOptional = DockerMachineClient.instance().getDefaultMachine(); checkArgument(machineNameOptional.isPresent(), "docker-machine is installed but no default machine could be found"); String machineName = machineNameOptional.get(); log.info("Found docker-machine, and will use machine named {}", machineName); DockerMachineClient.instance().ensureMachineRunning(machineName); String dockerDaemonIpAddress = DockerMachineClient.instance().getDockerDaemonIpAddress(machineName); log.info("Docker daemon IP address for docker machine {} is {}", machineName, dockerDaemonIpAddress); config = DefaultDockerClientConfig.createDefaultConfigBuilder() .withDockerHost("tcp://" + dockerDaemonIpAddress + ":2376") .withDockerTlsVerify(true) .withDockerCertPath(Paths.get(System.getProperty("user.home") + "/.docker/machine/certs/").toString()) .build(); client = getClientForConfig(config); } catch (Exception e) { throw new InvalidConfigurationException(e.getMessage()); } // If the docker-machine VM has started, the docker daemon may still not be ready. Retry pinging until it works. final int timeout = Integer.parseInt(System.getProperty(PING_TIMEOUT_PROPERTY_NAME, PING_TIMEOUT_DEFAULT)); ping(client, timeout); }
@NotNull protected DockerClientConfig tryConfiguration(String dockerHost) { Path dockerSocketFile = Paths.get(DOCKER_SOCK_PATH); Integer mode; try { mode = (Integer) Files.getAttribute(dockerSocketFile, "unix:mode"); } catch (IOException e) { throw new InvalidConfigurationException("Could not find unix domain socket", e); } if ((mode & 0xc000) != SOCKET_FILE_MODE_MASK) { throw new InvalidConfigurationException("Found docker unix domain socket but file mode was not as expected (expected: srwxr-xr-x). This problem is possibly due to occurrence of this issue in the past: https://github.com/docker/docker/issues/13121"); } config = DefaultDockerClientConfig.createDefaultConfigBuilder() .withDockerHost(dockerHost) .withDockerTlsVerify(false) .build(); client = getClientForConfig(config); final int timeout = Integer.parseInt(System.getProperty(PING_TIMEOUT_PROPERTY_NAME, PING_TIMEOUT_DEFAULT)); ping(client, timeout); return config; }
@Test public void getDockerHostIpAddressShouldReturnDockerHostIpWhenTcpUri() { DockerClientConfig configuration = DefaultDockerClientConfig.createDefaultConfigBuilder() .withDockerHost("tcp://12.23.34.45") .withDockerTlsVerify(false) // TODO - check wrt. https://github.com/docker-java/docker-java/issues/588 .build(); String actual = DockerClientConfigUtils.getDockerHostIpAddress(configuration); assertEquals("12.23.34.45", actual); }
@Test @Ignore public void getDockerHostIpAddressShouldReturnDockerHostIpWhenHttpsUri() { DockerClientConfig configuration = DefaultDockerClientConfig.createDefaultConfigBuilder().withDockerHost("https://12.23.34.45").build(); String actual = DockerClientConfigUtils.getDockerHostIpAddress(configuration); assertEquals("12.23.34.45", actual); }
@Test @Ignore public void getDockerHostIpAddressShouldReturnDockerHostIpWhenHttpUri() { DockerClientConfig configuration = DefaultDockerClientConfig.createDefaultConfigBuilder().withDockerHost("http://12.23.34.45").build(); String actual = DockerClientConfigUtils.getDockerHostIpAddress(configuration); assertEquals("12.23.34.45", actual); }
@Test public void getDockerHostIpAddressShouldReturnLocalhostWhenUnixSocket() { DockerClientConfig configuration = DefaultDockerClientConfig.createDefaultConfigBuilder() .withDockerHost("unix:///var/run/docker.sock") .withDockerTlsVerify(false) // TODO - check wrt. https://github.com/docker-java/docker-java/issues/588 .build(); String actual = DockerClientConfigUtils.getDockerHostIpAddress(configuration); assertEquals("localhost", actual); }
@Test @Ignore public void getDockerHostIpAddressShouldReturnNullWhenUnsupportedUriScheme() { DockerClientConfig configuration = DefaultDockerClientConfig.createDefaultConfigBuilder().withDockerHost("gopher://12.23.34.45").build(); String actual = DockerClientConfigUtils.getDockerHostIpAddress(configuration); assertNull(actual); } }
private void initClient() { config = DefaultDockerClientConfig.createDefaultConfigBuilder().build(); docker = DockerClientBuilder.getInstance(config) .build(); }