-
Yes a private network is defined for each run of the job, and service container is started with network alias specified as service name, which can be accessed as host name. The logic to start service container is as below:
String image = (String) jobService.get("image"); docker.clearArgs(); boolean useProcessIsolation = isUseProcessIsolation(docker, image, nodeOsInfo, jobLogger); jobLogger.log("Creating service container..."); String containerName = network + "-service-" + jobService.get("name"); docker.clearArgs(); docker.addArgs("run", "-d", "--name=" + containerName, "--network=" + network, "--network-alias=" + jobService.get("name")); if (cpuLimit != null) docker.addArgs("--cpus", cpuLimit); if (memoryLimit != null) docker.addArgs("--memory", memoryLimit); for (Map.Entry<String, String> entry : ((Map<String, String>) jobService.get("envVars")).entrySet()) docker.addArgs("--env", entry.getKey() + "=" + entry.getValue()); if (useProcessIsolation) docker.addArgs("--isolation=process"); docker.addArgs(image); if (jobService.get("arguments") != null) { for (String token : StringUtils.parseQuoteTokens((String) jobService.get("arguments"))) docker.addArgs(token); } -
Perfect, thanks !!
-
Previous Value Current Value Open
Closed
| Type |
Question
|
| Priority |
Normal
|
| Assignee |
Issue Votes (0)
Hi,
No issue, just technical discussion on how you call docker client from job buildspec
As perfectly describe here, i'm using a service for a CI Database job to test and valid my database script creation and update.
Everything works but i'm wondering :
I think you create a private network to avoid this port collision and in addition, allow network connection using container name ?
Thanks for your lights