|
@@ -153,7 +153,40 @@ public class DockerExe {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ public static void runMdo3(String pid) {
|
|
|
+ DockerClientConfig config = DefaultDockerClientConfig.createDefaultConfigBuilder()
|
|
|
+ .withDockerHost(DOCKERHOST) // 设置 Docker 主机地址
|
|
|
+ .withDockerTlsVerify(false) // 启用 TLS 验证
|
|
|
+ .withApiVersion(APIVERSION) // 设置 API 版本
|
|
|
+ .build();
|
|
|
+ DockerHttpClient httpClient = new ApacheDockerHttpClient.Builder()
|
|
|
+ .dockerHost(config.getDockerHost())
|
|
|
+ .sslConfig(config.getSSLConfig())
|
|
|
+ .build();
|
|
|
+ DockerClient dockerClient = DockerClientBuilder.getInstance(config)
|
|
|
+ .withDockerHttpClient(httpClient)
|
|
|
+ .build();
|
|
|
+
|
|
|
+ Mount wokerMount = new Mount()
|
|
|
+ .withType(MountType.BIND)
|
|
|
+ .withSource("/cephfs/mdo/"+pid+"/in/")
|
|
|
+ .withTarget("/cephfs/mdo/"+pid+"/in/")
|
|
|
+ .withReadOnly(false);
|
|
|
+ List<Mount> am =new ArrayList<>();
|
|
|
+ am.add(wokerMount);
|
|
|
|
|
|
+ //创建容器
|
|
|
+ CreateContainerResponse container = dockerClient
|
|
|
+ .createContainerCmd("surromdao:2.0")//镜像名称
|
|
|
+ .withName(pid)//容器名称
|
|
|
+ .withHostConfig(
|
|
|
+ HostConfig.newHostConfig()
|
|
|
+ .withMounts(am)
|
|
|
+ ).withCmd("bash", "-c", "source /home/mdo/aeroelastic.sh && cd /cephfs/mdo/"+pid+"/in && conda activate surromdao && mpiexec -n 1 python run.py")
|
|
|
+ .exec();
|
|
|
+ dockerClient.startContainerCmd(container.getId()).exec();
|
|
|
+ System.out.println("容器启动成功,ID: " + container.getId());
|
|
|
+ }
|
|
|
|
|
|
public static void runMdo2(String pid) {
|
|
|
DockerClientConfig config = DefaultDockerClientConfig.createDefaultConfigBuilder()
|
|
@@ -179,12 +212,12 @@ public class DockerExe {
|
|
|
|
|
|
//创建容器
|
|
|
CreateContainerResponse container = dockerClient
|
|
|
- .createContainerCmd("surromdao:2.0")//镜像名称
|
|
|
+ .createContainerCmd("surromdao:1.0")//镜像名称
|
|
|
.withName(pid)//容器名称
|
|
|
.withHostConfig(
|
|
|
HostConfig.newHostConfig()
|
|
|
.withMounts(am)
|
|
|
- ).withCmd("bash", "-c", "source /home/mdo/aeroelastic.sh && cd /cephfs/mdo/"+pid+"/in && conda activate surromdao && mpiexec -n 1 python run.py")
|
|
|
+ ).withCmd("bash", "-c", "source /home/mdo/aeroelastic.sh && cd /cephfs/mdo/"+pid+"/in && mpiexec -n 1 python run.py")
|
|
|
.exec();
|
|
|
dockerClient.startContainerCmd(container.getId()).exec();
|
|
|
System.out.println("容器启动成功,ID: " + container.getId());
|