MCPcopy Create free account
hub / github.com/OpenAtomFoundation/SmartIDE / GetLocalContainersWithServices

Function GetLocalContainersWithServices

cli/cmd/start/env.go:48–68  ·  view source on GitHub ↗

获取docker compose运行起来对应的容器

(ctx context.Context, cli *client.Client,
	workingDir string, dockerComposeServices []string)

Source from the content-addressed store, hash-verified

46
47// 获取docker compose运行起来对应的容器
48func GetLocalContainersWithServices(ctx context.Context, cli *client.Client,
49 workingDir string, dockerComposeServices []string) []DockerComposeContainer {
50
51 var dockerComposeContainers []DockerComposeContainer // result define
52
53 // home dir
54 if workingDir[0:1] == "~" {
55 homeDir, _ := os.UserHomeDir()
56 workingDir = filepath.Join(homeDir, workingDir[1:])
57 }
58
59 //通过cli客户端对象去执行ContainerList(其实docker ps 不就是一个docker正在运行容器的一个list嘛)
60 containers, err2 := cli.ContainerList(ctx, types.ContainerListOptions{})
61 common.CheckError(err2)
62 dockerComposeContainers = convertOriginContainer(containers, workingDir, dockerComposeServices)
63
64 // 打印
65 PrintDockerComposeContainers(dockerComposeContainers)
66
67 return dockerComposeContainers
68}
69
70// 检测远程服务器的环境,是否安装docker、docker-compose、git
71func GetRemoteContainersWithServices(sshRemote common.SSHRemote,

Callers 2

ExecuteStartCmdFunction · 0.85
isDockerComposeRunningFunction · 0.85

Calls 3

convertOriginContainerFunction · 0.85
JoinMethod · 0.45

Tested by

no test coverage detected