1

I would like to know how to findout the configured container-runtime of your docker-client. Preferably in a programmatic way with golang.

I know those to packages for golang handling containers with containerd and docker-engine: https://pkg.go.dev/github.com/containerd/containerd https://pkg.go.dev/github.com/docker/docker/client

And I know that Kubernetes offers interface to receive the runtime used on each client: https://kubernetes.io/docs/tasks/administer-cluster/migrating-from-dockershim/find-out-runtime-you-use

But as mentioned I would like to know a programmatic way, preferably with golang. Because not every docker-client is a kubernetes Pod ;)

Nikolai Ehrhardt
  • 570
  • 4
  • 14
  • 1
    The ["Get system information" REST API call](https://docs.docker.com/engine/api/v1.42/#tag/System/operation/SystemInfo) includes a `DefaultRuntime` field; is that the information you need? That's also exposed in the Go [`types.Info`](https://pkg.go.dev/github.com/docker/docker@v23.0.5+incompatible/api/types#Info) structure. (Why do you need to know this?) – David Maze Apr 27 '23 at 11:17
  • One way is to go with API as @DavidMaze mentioned. If the task is simpler like some script, you could use docker tool: `docker inspect my-container-1 -f '{{ .HostConfig.Runtime }}'`. – muradm Apr 27 '23 at 12:35
  • I actually worry about the necessary API to use for each container-runtime. – Nikolai Ehrhardt Apr 30 '23 at 11:38

0 Answers0