|
|
@@ -198,9 +198,12 @@ public class DockerImpl implements Docker {
|
|
|
createContainerCmd.withEnv(env);
|
|
|
}
|
|
|
|
|
|
+ RestartPolicy restartPolicy = RestartPolicy.onFailureRestart(3);
|
|
|
HostConfig hostConfig = HostConfig.newHostConfig()
|
|
|
+ // --init 参数
|
|
|
+ //.withInit(true)
|
|
|
.withNetworkMode("host")
|
|
|
- .withRestartPolicy(RestartPolicy.unlessStoppedRestart());
|
|
|
+ .withRestartPolicy(restartPolicy);
|
|
|
if (containerConfig.getVolumes() != null) {
|
|
|
Map<String, String> map = containerConfig.getVolumes().getMap();
|
|
|
List<Bind> list = new ArrayList<>();
|
|
|
@@ -214,6 +217,10 @@ public class DockerImpl implements Docker {
|
|
|
hostConfig.withBinds(list);
|
|
|
}
|
|
|
|
|
|
+ if (containerConfig.getHostConfig().getInit() != null) {
|
|
|
+ hostConfig.withInit(containerConfig.getHostConfig().getInit());
|
|
|
+ }
|
|
|
+
|
|
|
createContainerCmd.withHostConfig(hostConfig);
|
|
|
CreateContainerResponse response = createContainerCmd.exec();
|
|
|
String containerId = response.getId();
|