24 lines
667 B
Java
24 lines
667 B
Java
package com.guwan.backend.service;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import com.github.dockerjava.api.DockerClient;
|
|
import com.github.dockerjava.api.model.Info;
|
|
|
|
@Service
|
|
public class DockerService {
|
|
|
|
private final DockerClient dockerClient;
|
|
|
|
// 通过构造函数注入 DockerClient
|
|
@Autowired
|
|
public DockerService(DockerClient dockerClient) {
|
|
this.dockerClient = dockerClient;
|
|
}
|
|
|
|
public void printDockerInfo() {
|
|
Info info = dockerClient.infoCmd().exec(); // 获取 Docker 守护进程的信息
|
|
System.out.println(info.toString());
|
|
}
|
|
}
|