amihaiemil / amihaiemil/docker-java-api

How to run a Exec

Đang mở
#386 1 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Java
Star
274
Fork
56
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

How to run the Exec instance after create it, I have dig throught the repo but cant find a way to make it work, here is my code below:

```Java
public String testDockerClient () {
try{
final Docker dockerClient = new UnixDocker(new File("/var/run/docker.sock"));
final Container started = dockerClient.containers().create("my-python-runner:latest");

JsonArray cmdArray = Json.createArrayBuilder()
.add("echo")
.add("helloword")
.build();

JsonObject execConfig = Json.createObjectBuilder()
.add("Cmd", cmdArray)
.add("AttachStdin", false)
.add("AttachStdout", true)
.add("AttachStderr", true)
.add("Tty", false)
.build();

started.start();

Exec output = started.exec(execConfig);
System.out.println("output: " + output.inspect());
Logs log = started.logs();
System.out.println("log: " + log.toString());
started.stop();
started.remove();

return "Success";

} catch (Exception e) {
return "Error: " + e.getMessage();
}
```

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.