|
@@ -21,7 +21,7 @@ public class DockerExe {
|
|
|
public static final String DOCKERHOST="tcp://192.168.0.132:2375/";
|
|
|
public static final String APIVERSION="1.13.1";
|
|
|
// 获取容器信息
|
|
|
- public static String getDocker(Integer aid){
|
|
|
+ public static String getDocker(Integer aid,String stype){
|
|
|
DockerClientConfig config = DefaultDockerClientConfig.createDefaultConfigBuilder()
|
|
|
.withDockerHost(DOCKERHOST) // 设置 Docker 主机地址
|
|
|
.withDockerTlsVerify(false) // 启用 TLS 验证
|
|
@@ -34,7 +34,7 @@ public class DockerExe {
|
|
|
DockerClient dockerClient = DockerClientBuilder.getInstance(config)
|
|
|
.withDockerHttpClient(httpClient)
|
|
|
.build();
|
|
|
- InspectContainerResponse containerInfo = dockerClient.inspectContainerCmd(aid.toString()).exec();
|
|
|
+ InspectContainerResponse containerInfo = dockerClient.inspectContainerCmd(stype+"_"+aid.toString()).exec();
|
|
|
//exited 停止 running 运行
|
|
|
try{
|
|
|
return containerInfo.getState().getStatus();
|
|
@@ -44,7 +44,7 @@ public class DockerExe {
|
|
|
|
|
|
|
|
|
}
|
|
|
- private static void stopDocker(Integer aid){
|
|
|
+ public static void stopDocker(Integer aid, String stype){
|
|
|
DockerClientConfig config = DefaultDockerClientConfig.createDefaultConfigBuilder()
|
|
|
.withDockerHost(DOCKERHOST) // 设置 Docker 主机地址
|
|
|
.withDockerTlsVerify(false) // 启用 TLS 验证
|
|
@@ -58,7 +58,7 @@ public class DockerExe {
|
|
|
.withDockerHttpClient(httpClient)
|
|
|
.build();
|
|
|
try {
|
|
|
- dockerClient.stopContainerCmd(aid.toString())
|
|
|
+ dockerClient.stopContainerCmd(stype+"_"+aid.toString())
|
|
|
.withTimeout(1000)
|
|
|
.exec();
|
|
|
dockerClient.removeConfigCmd(aid.toString())
|
|
@@ -87,7 +87,6 @@ public class DockerExe {
|
|
|
.withStdOut(true)
|
|
|
.withStdErr(true)
|
|
|
.withFollowStream(true);
|
|
|
-
|
|
|
// 使用 ResultCallback.Adapter 处理日志
|
|
|
logContainerCmd.exec(logsexe).awaitCompletion();
|
|
|
}
|