Version version = client.versionCmd().exec(); activeApiVersion = version.getApiVersion(); activeExecutionDriver = dockerInfo.getExecutionDriver(); log.info("Connected to docker: \n" + " Server Version: " + dockerInfo.getServerVersion() + "\n" + " API Version: " + activeApiVersion + "\n" + " Operating System: " + dockerInfo.getOperatingSystem() + "\n" + " Total Memory: " + dockerInfo.getMemTotal() / (1024 * 1024) + " MB");
private Map<String, String> resolveSystemDefaultSetup(Map<String, String> config) { if (!config.containsKey(CubeDockerConfiguration.DOCKER_URI)) { final String defaultUri = operatingSystem.getDefaultFamily().getServerUri(); URI uri = URI.create(defaultUri); if (Files.exists(FileSystems.getDefault().getPath(uri.getPath()))){ DockerClient client = defaultDocker.getDefaultDockerClient(defaultUri); InfoCmd cmd = client.infoCmd(); try { Info info = cmd.exec(); config.put(CubeDockerConfiguration.DOCKER_URI, defaultUri); log.info(String.format("Connected to docker (%s) using default settings version: %s kernel: %s", info.getName(), info.getServerVersion(), info.getKernelVersion())); } catch (ProcessingException e){ log.info(String.format("Could not connect to default socket %s. Go on with ", operatingSystem.getDefaultFamily().getServerUri())); } } } return config; }
ObjectMapper mapper = new ObjectMapper(); Root readValue = mapper.readValue( new FileReader("src/main/sources/routes.txt"), Root.class); Info info = readValue.getInfo(); System.out.println(info.toString()); //Remove from production code Stops stops = info.getStops(); System.out.println(stops.toString()); //Remove from production code
private Map<String, String> resolveSystemDefaultSetup(Map<String, String> config) { if (!config.containsKey(CubeDockerConfiguration.DOCKER_URI)) { final String defaultUri = operatingSystem.getDefaultFamily().getServerUri(); URI uri = URI.create(defaultUri); if (Files.exists(FileSystems.getDefault().getPath(uri.getPath()))){ DockerClient client = defaultDocker.getDefaultDockerClient(defaultUri); InfoCmd cmd = client.infoCmd(); try { Info info = cmd.exec(); config.put(CubeDockerConfiguration.DOCKER_URI, defaultUri); log.info(String.format("Connected to docker (%s) using default settings version: %s kernel: %s", info.getName(), info.getServerVersion(), info.getKernelVersion())); } catch (ProcessingException e){ log.info(String.format("Could not connect to default socket %s. Go on with ", operatingSystem.getDefaultFamily().getServerUri())); } } } return config; }
Version version = client.versionCmd().exec(); activeApiVersion = version.getApiVersion(); activeExecutionDriver = dockerInfo.getExecutionDriver(); log.info("Connected to docker: \n Server Version: " + dockerInfo.getServerVersion() + "\n API Version: " + activeApiVersion + "\n Operating System: " + dockerInfo.getOperatingSystem() + "\n Total Memory: " + dockerInfo.getMemTotal() / (1024 * 1024) + " MB"); String ryukContainerId = null; boolean useRyuk = !Boolean.parseBoolean(System.getenv("TESTCONTAINERS_RYUK_DISABLED"));
@Test public void shouldDetectsValidDockerDefault() throws Exception { CubeDockerConfigurationResolver resolver = new CubeDockerConfigurationResolver(new Top(), new DockerMachine(null), new Boot2Docker(null), mockDefaultDocker(), operatingSystemInterface); when(info.getName()).thenReturn("docker-ce"); when(info.getServerVersion()).thenReturn("arquillian-test"); when(info.getKernelVersion()).thenReturn("0.0.0"); URL sockURL = this.getClass().getClassLoader().getResource("docker.sock"); String sockUri = "unix://" + sockURL; when(defaultOperatingSystemFamilyInterface.getServerUri()).thenReturn(sockUri); when(operatingSystemInterface.getDefaultFamily()).thenReturn(defaultOperatingSystemFamilyInterface); when(operatingSystemInterface.getFamily()).thenReturn(OperatingSystem.MAC_OSX.getFamily()); Map<String, String> config = new HashMap<>(); Map<String, String> resolvedConfig = resolver.resolve(config); assertThat(Boolean.valueOf(resolvedConfig.get(CubeDockerConfiguration.TLS_VERIFY)), is(false)); assertThat(resolvedConfig.get(CubeDockerConfiguration.CERT_PATH), is(nullValue())); assertThat(resolvedConfig.get(CubeDockerConfiguration.DOCKER_URI), is(sockUri)); }