From c9acf34a5bfd34111e48e84f4247128cce02ecac Mon Sep 17 00:00:00 2001 From: Late Night Defender Date: Thu, 16 May 2024 17:23:43 +0700 Subject: [PATCH] run docker daemon manually in CI environment --- docker.go | 9 +++++++++ main.go | 1 + 2 files changed, 10 insertions(+) diff --git a/docker.go b/docker.go index f1fff49..723e4cf 100644 --- a/docker.go +++ b/docker.go @@ -4,6 +4,7 @@ import ( "fmt" "time" "context" + "os" "github.com/docker/docker/api/types/container" "github.com/docker/docker/client" "github.com/docker/go-connections/nat" @@ -19,6 +20,14 @@ func dockerPullMongo() { ExecSystem("docker pull mongo") } +func checkDockerExistence() { + filePath := "/var/run/docker.sock" + + _, err := os.Stat(filePath) + if os.IsNotExist(err) { + ExecSystem("dockerd &") + } +} func dockerRunMongo() { cli, err := client.NewClientWithOpts(client.FromEnv) diff --git a/main.go b/main.go index 4519db1..33b60a4 100644 --- a/main.go +++ b/main.go @@ -87,6 +87,7 @@ func main() { checkSettings() instDeps() genKeys() + checkDockerExistence() dockerNetworkCreate() dockerPullMongo() dockerRunMongo()