Java操作Docker的Api接口工具类
public class DockerClientService {
private static final Logger LOGGER = LoggerFactory.getLogger(DockerClientService.class);
/**
* 连接docker服务器
*
* @return
*/
public DockerClient connectDocker(String serverUrl) {
DockerClient dockerClient = DockerClientBuilder.getInstance(serverUrl).build();
Info info = dockerClient.infoCmd().exec();
LOGGER.debug("================= Docker环境信息:================= \n{}", info);
return dockerClient;
}
/**
* 创建容器
*
* @param client
* @param containerName
* @param imageName
* @param exposedTcpPort
* @param bindTcpPort
* @return
*/
public CreateContainerResponse createContainer(DockerClient client, String containerName, String imageName,
int exposedTcpPort, int bindTcpPort) {
ExposedPort exposedPort = ExposedPort.tcp(exposedTcpPort);
Ports portBin

最低0.47元/天 解锁文章
1511

被折叠的 条评论
为什么被折叠?



