|
@@ -60,25 +60,25 @@ public class DockerExe {
|
|
|
.withDockerHttpClient(httpClient)
|
|
|
.build();
|
|
|
try {
|
|
|
- InspectContainerResponse containerInfo = dockerClient.inspectContainerCmd(stype+"_"+aid.toString()).exec();
|
|
|
- //exited 停止 running 运行
|
|
|
- String status ="error";
|
|
|
- try{
|
|
|
- status= containerInfo.getState().getStatus();
|
|
|
- }catch (Exception e){
|
|
|
-
|
|
|
- }
|
|
|
- if("running".equals(status)){
|
|
|
- dockerClient.stopContainerCmd(stype+"_"+aid.toString())
|
|
|
- .withTimeout(1000)
|
|
|
- .exec();
|
|
|
- }
|
|
|
- if("exited".equals(status)){
|
|
|
+// InspectContainerResponse containerInfo = dockerClient.inspectContainerCmd(stype+"_"+aid.toString()).exec();
|
|
|
+// //exited 停止 running 运行
|
|
|
+// String status ="error";
|
|
|
+// try{
|
|
|
+// status= containerInfo.getState().getStatus();
|
|
|
+// }catch (Exception e){
|
|
|
+//
|
|
|
+// }
|
|
|
+// if("running".equals(status)){
|
|
|
+// dockerClient.stopContainerCmd(stype+"_"+aid.toString())
|
|
|
+// .withTimeout(1000)
|
|
|
+// .exec();
|
|
|
+// }
|
|
|
+// if("exited".equals(status)){
|
|
|
RemoveContainerCmd removeContainerCmd = dockerClient.removeContainerCmd(stype+"_"+aid.toString())
|
|
|
.withForce(true);
|
|
|
removeContainerCmd.exec();
|
|
|
|
|
|
- }
|
|
|
+// }
|
|
|
System.out.println("容器已停止: " + aid.toString());
|
|
|
} catch (Exception e) {
|
|
|
System.err.println("停止容器失败: " + e.getMessage());
|