How to use getDefaultMachine method of org.testcontainers.utility.DockerMachineClient class

Best Testcontainers-java code snippet using org.testcontainers.utility.DockerMachineClient.getDefaultMachine

Source:DockerMachineClient.java Github

copy

Full Screen

...40 }41 public boolean isInstalled() {42 return executableExists(executableName);43 }44 public Optional<String> getDefaultMachine() {45 String ls = runShellCommand(executableName, "ls", "-q");46 List<String> machineNames = asList(ls.split("\n"));47 String envMachineName = System.getenv("DOCKER_MACHINE_NAME");48 if (machineNames.contains(envMachineName)) {49 LOGGER.debug("Using docker-machine set in DOCKER_MACHINE_NAME: {}", envMachineName);50 return Optional.of(envMachineName);51 } else if (machineNames.contains("default")) {52 LOGGER.debug("DOCKER_MACHINE_NAME is not set; Using 'default' docker-machine", envMachineName);53 return Optional.of("default");54 } else if (machineNames.size() > 0) {55 LOGGER.debug("DOCKER_MACHINE_NAME is not set and no machine named 'default' found; Using first machine found with `docker-machine ls`: {}", machineNames.get(0));56 return Optional.of(machineNames.get(0));57 } else {58 return Optional.empty();59 }60 }61 public void ensureMachineRunning(@NonNull String machineName) {62 if (!isMachineRunning(machineName)) {63 LOGGER.info("Docker-machine '{}' is not running. Will start it now", machineName);64 runShellCommand("docker-machine", "start", machineName);65 }66 }67 /**68 * @deprecated Use getDockerDaemonUrl(@NonNull String machineName) for connection to docker-machine69 */70 @Deprecated71 public String getDockerDaemonIpAddress(@NonNull String machineName) {72 return runShellCommand(executableName, "ip", machineName);73 }74 public String getDockerDaemonUrl(@NonNull String machineName) {75 return runShellCommand(executableName, "url", machineName);76 }77 public boolean isMachineRunning(String machineName) {78 String status = runShellCommand("docker-machine", "status", machineName);79 return status.trim().equalsIgnoreCase("running");80 }81 public boolean isDefaultMachineRunning() {82 return isMachineRunning(getDefaultMachine().orElse("default"));83 }84}...

Full Screen

Full Screen

Source:DockerMachineClientProviderStrategy.java Github

copy

Full Screen

...21 private final TransportConfig transportConfig = resolveTransportConfig();22 private TransportConfig resolveTransportConfig() throws InvalidConfigurationException {23 boolean installed = DockerMachineClient.instance().isInstalled();24 checkArgument(installed, "docker-machine executable was not found on PATH (" + Arrays.toString(CommandLine.getSystemPath()) + ")");25 Optional<String> machineNameOptional = DockerMachineClient.instance().getDefaultMachine();26 checkArgument(machineNameOptional.isPresent(), "docker-machine is installed but no default machine could be found");27 String machineName = machineNameOptional.get();28 log.info("Found docker-machine, and will use machine named {}", machineName);29 DockerMachineClient.instance().ensureMachineRunning(machineName);30 String dockerDaemonUrl = DockerMachineClient.instance().getDockerDaemonUrl(machineName);31 log.info("Docker daemon URL for docker machine {} is {}", machineName, dockerDaemonUrl);32 return TransportConfig.builder()33 .dockerHost(URI.create(dockerDaemonUrl))34 .sslConfig(35 new LocalDirectorySSLConfig(36 Paths.get(System.getProperty("user.home") + "/.docker/machine/certs/").toString()37 )38 )39 .build();40 }41 @Override42 protected boolean isApplicable() {43 boolean installed = DockerMachineClient.instance().isInstalled();44 if (!installed) {45 log.info("docker-machine executable was not found on PATH ({})", Arrays.toString(CommandLine.getSystemPath()));46 return false;47 }48 Optional<String> machineNameOptional = DockerMachineClient.instance().getDefaultMachine();49 if (!machineNameOptional.isPresent()) {50 log.info("docker-machine is installed but no default machine could be found");51 }52 return true;53 }54 @Override55 protected boolean isPersistable() {56 return false;57 }58 @Override59 protected int getPriority() {60 return EnvironmentAndSystemPropertyClientProviderStrategy.PRIORITY - 100;61 }62 @Override...

Full Screen

Full Screen

getDefaultMachine

Using AI Code Generation

copy

Full Screen

1import org.testcontainers.DockerClientFactory;2import org.testcontainers.utility.DockerMachineClient;3public class DefaultMachine {4 public static void main(String[] args) {5 DockerMachineClient dockerMachineClient = DockerClientFactory.instance().dockerMachineClient();6 String defaultMachine = dockerMachineClient.getDefaultMachine();7 System.out.println("Default machine is: " + defaultMachine);8 }9}10Source Project: testcontainers-java Source File: DockerMachineClientTest.java License: Apache License 2.0 6 votes public void testGetDefaultMachine() { DockerMachineClient dockerMachineClient = new DockerMachineClient(); String defaultMachine = dockerMachineClient.getDefaultMachine(); assertEquals("default", defaultMachine); }11Source Project: testcontainers-java Source File: DockerMachineClientTest.java License: Apache License 2.0 6 votes public void testGetDefaultMachine() { DockerMachineClient dockerMachineClient = new DockerMachineClient(); String defaultMachine = dockerMachineClient.getDefaultMachine(); assertEquals("default", defaultMachine); }12Source Project: testcontainers-java Source File: DockerMachineClientTest.java License: Apache License 2.0 6 votes public void testGetDefaultMachine() { DockerMachineClient dockerMachineClient = new DockerMachineClient(); String defaultMachine = dockerMachineClient.getDefaultMachine(); assertEquals("default", defaultMachine); }13Source Project: testcontainers-java Source File: DockerMachineClientTest.java License: Apache License 2.0 6 votes public void testGetDefaultMachine() { DockerMachineClient dockerMachineClient = new DockerMachineClient(); String defaultMachine = dockerMachineClient.getDefaultMachine(); assertEquals("default", defaultMachine); }14Source Project: testcontainers-java Source File: DockerMachineClientTest.java License: Apache License 2.0 6 votes public void testGetDefaultMachine() { DockerMachineClient dockerMachineClient = new DockerMachineClient(); String defaultMachine = dockerMachineClient.getDefaultMachine(); assertEquals("default", defaultMachine); }15Source Project: testcontainers-java Source File: DockerMachineClientTest.java License: Apache License 2.0 6 votes public void testGetDefaultMachine() { DockerMachineClient dockerMachineClient

Full Screen

Full Screen

getDefaultMachine

Using AI Code Generation

copy

Full Screen

1package org.testcontainers.utility;2import java.io.IOException;3import com.github.dockerjava.api.DockerClient;4import com.github.dockerjava.core.DockerClientBuilder;5import com.github.dockerjava.core.DockerClientConfig;6import com.github.dockerjava.core.DockerClientConfig.DockerClientConfigBuilder;7import com.github.dockerjava.core.DockerClientImpl;8import com.github.dockerjava.core.LocalDirectorySSLConfig;9import com.github.dockerjava.core.RemoteApiVersion;10import com.github.dockerjava.core.SSLConfig;11import com.github.dockerjava.jaxrs.JerseyDockerCmdExecFactory;12import com.github.dockerjava.jaxrs.JerseyDockerCmdExecFactory.JerseyDockerCmdExecFactoryBuilder;13import com.github.dockerjava.transport.DockerHttpClient;14import com.github.dockerjava.transport.DockerHttpClientImpl;15import com.github.dockerjava.transport.DockerHttpClientImpl.DockerHttpClientImplBuilder;16import com.github.dockerjava.transport.SSLConfigurableSocketFactory;17import com.github.dockerjava.transport.SSLConfigurableSocketFactory.SSLConfigurableSocketFactoryBuilder;18import com.github.dockerjava.transport.UnixSocket;19import com.github.dockerjava.transport.UnixSocketClientBuilder;20import com.github.dockerjava.transport.UnixSocketClientBuilder.UnixSocketClientBuilderBuilder;21import com.google.common.base.Optional;22import com.google.common.base.Strings;23import com.google.common.net.HostAndPort;24import java.io.File;25import java.util.ArrayList;26import java.util.Arrays;27import java.util.List;28import java.util.Map;29import java.util.concurrent.TimeUnit;30import javax.net.ssl.SSLContext;31import javax.net.ssl.SSLParameters;32import javax.net.ssl.SSLSocketFactory;33import org.apache.commons.lang.SystemUtils;34import org.apache.http.HttpHost;35import org.apache.http.client.HttpClient;36import org.apache.http.config.Registry;37import org.apache.http.config.RegistryBuilder;38import org.apache.http.conn.socket.ConnectionSocketFactory;39import org.apache.http.conn.socket.PlainConnectionSocketFactory;40import org.apache.http.conn.ssl.SSLConnectionSocketFactory;41import org.apache.http.impl.client.CloseableHttpClient;42import org.apache.http.impl.client.HttpClientBuilder;43import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;44import org.apache.http.impl.conn.PoolingHttpClientConnectionManagerBuilder;45import org.apache.http.impl.conn.SystemDefaultDnsResolver;46import org.apache.http.ssl.SSLContexts;47import org.apache.http.ssl.SSLInitializationException;48import org.apache.http.ssl.TrustStrategy;49import org.slf4j.Logger

Full Screen

Full Screen

getDefaultMachine

Using AI Code Generation

copy

Full Screen

1package org.testcontainers;2import org.testcontainers.utility.DockerMachineClient;3public class TestDockerMachineClient {4 public static void main(String[] args) {5 DockerMachineClient client = DockerMachineClient.instance();6 System.out.println(client.getDefaultMachine());7 }8}

Full Screen

Full Screen

getDefaultMachine

Using AI Code Generation

copy

Full Screen

1import org.testcontainers.utility.DockerMachineClient;2import java.io.IOException;3public class 1 {4 public static void main(String[] args) throws IOException {5 System.out.println(DockerMachineClient.instance().getDefaultMachine().getIp());6 }7}8import org.testcontainers.utility.DockerMachineClient;9import java.io.IOException;10public class 2 {11 public static void main(String[] args) throws IOException {12 System.out.println(DockerMachineClient.instance().getDockerHostIpAddress());13 }14}15import org.testcontainers.utility.DockerMachineClient;16import java.io.IOException;17public class 3 {18 public static void main(String[] args) throws IOException {19 System.out.println(DockerMachineClient.instance().getDockerHostIpAddress());20 }21}22import org.testcontainers.utility.DockerMachineClient;23import java.io.IOException;24public class 4 {25 public static void main(String[] args) throws IOException {26 System.out.println(DockerMachineClient.instance().getDockerHostIpAddress());27 }28}29import org.testcontainers.utility.DockerMachineClient;30import java.io.IOException;31public class 5 {32 public static void main(String[] args) throws IOException {33 System.out.println(DockerMachineClient.instance().getDockerHostIpAddress());34 }35}36import org.testcontainers.utility.DockerMachineClient;37import java.io.IOException;38public class 6 {39 public static void main(String[] args) throws IOException {40 System.out.println(DockerMachineClient.instance().getDockerHostIpAddress());41 }42}43import org.testcontainers.utility.DockerMachineClient;44import java.io.IOException;45public class 7 {

Full Screen

Full Screen

getDefaultMachine

Using AI Code Generation

copy

Full Screen

1import org.testcontainers.utility.DockerMachineClient;2import org.testcontainers.utility.MachineProvider;3import org.testcontainers.utility.MachineProviderStrategy;4import org.testcontainers.utility.ResourceReaper;5import org.testcontainers.utility.TestcontainersConfiguration;6public class 1 {7 public static void main(String[] args) {8 MachineProviderStrategy strategy = MachineProviderStrategy.getStrategy();9 MachineProvider provider = strategy.getProvider();10 DockerMachineClient dockerMachineClient = new DockerMachineClient(provider, new TestcontainersConfiguration(), new ResourceReaper());11 System.out.println(dockerMachineClient.getDefaultMachine());12 }13}14Your name to display (optional):

Full Screen

Full Screen

getDefaultMachine

Using AI Code Generation

copy

Full Screen

1package org.testcontainers.utility;2import java.io.IOException;3public class DockerMachineClientTest {4 public static void main(String[] args) throws IOException {5 DockerMachineClient client = DockerMachineClient.instance();6 String defaultMachine = client.getDefaultMachine();7 System.out.println("Default Machine: " + defaultMachine);8 }9}

Full Screen

Full Screen

getDefaultMachine

Using AI Code Generation

copy

Full Screen

1import org.testcontainers.utility.DockerMachineClient;2public class DockerMachineClientDemo {3 public static void main(String args[]) {4 String defaultMachine = DockerMachineClient.instance().getDefaultMachine();5 System.out.println("Default machine: " + defaultMachine);6 }7}8import org.testcontainers.utility.DockerMachineClient;9public class DockerMachineClientDemo {10 public static void main(String args[]) {11 String dockerHostIpAddress = DockerMachineClient.instance().getDockerHostIpAddress();12 System.out.println("Docker host ip address: " + dockerHostIpAddress);13 }14}

Full Screen

Full Screen

getDefaultMachine

Using AI Code Generation

copy

Full Screen

1import org.testcontainers.utility.DockerMachineClient;2import org.testcontainers.utility.MachineProvider;3public class 1 {4 public static void main(String[] args) {5 DockerMachineClient dockerMachineClient = new DockerMachineClient();6 MachineProvider defaultMachine = dockerMachineClient.getDefaultMachine();7 }8}

Full Screen

Full Screen

getDefaultMachine

Using AI Code Generation

copy

Full Screen

1package org.testcontainers.dockerclient;2import org.testcontainers.utility.DockerMachineClient;3public class DockerMachineClientGetDefaultMachine {4 public static void main(String[] args) {5 DockerMachineClient dockerMachineClient = DockerMachineClient.instance();6 String defaultMachine = dockerMachineClient.getDefaultMachine();7 System.out.println("defaultMachine = " + defaultMachine);8 }9}

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Testcontainers-java automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful