Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions pkg/docker.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package pkg

import (
"os"

"github.com/docker/docker/client"
)

func ListContainers() {
dockerSocketPath := os.Getenv("DOCKER_SOCKET_PATH")
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to use a different Docker context in order for the client to work.

Before that, I'd run into this error:

2024/08/27 16:47:21 Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?


apiClient, err := client.NewClientWithOpts(client.WithHost(dockerSocketPath))
if err != nil {
panic(err)
}
defer apiClient.Close()
}