Docker Community Forums

Share and learn in the Docker community.

How to check docker version whether it community or enterprise in linux container kubernetes

how to check docker version whether it community or enterprise in linux container kubernetes

Kubernetes is a tool for orchestrating and managing Docker containers. Red Hat provides several ways you can use Kubernetes including:

OpenShift Container Platform: Kubernetes is built into OpenShift, allowing you to configure Kubernetes, assign host computers as Kubernetes nodes, deploy containers to those nodes in pods, and manage containers across multiple systems. The OpenShift Container Platform web console provides a browser-based interface to using Kubernetes.
Container Development Kit (CDK): The CDK provides Vagrantfiles to launch the CDK with either OpenShift (which includes Kubernetes) or a bare-bones Kubernetes configuration. This gives you the choice of using the OpenShift tools or Kubernetes commands (such as kubectl) to manage Kubernetes.
Kubernetes in Red Hat Enterprise Linux: To try out Kubernetes on a standard Red Hat Enterprise Linux server system, you can install a combination of RPM packages and container images to manually set up your own Kubernetes configuration.
The procedures in this section describe how to set up Kubernetes using the last listed option - Kubernetes on Red Hat Enterprise Linux or Red Hat Enterprise Linux Atomic Host. Specifically, in this chapter you set up a single-system Kubernetes sandbox so you can:

Deploy and run two containers with Kubernetes on a single system.
Manage those containers in pods with Kubernetes.

Either you query the information from the engine’s rest-api or even better you add an ENV variable that injects the value while deploying the container.

To query the details from the engine’s rest-api, you will need the docker cli in the image AND you will need to provide access to either /var/run/docker.sock or a tcp socket (which is not enabled by default!).

You can get the required detail from docker version --format '{{.Server.Platform.Name}}'

Instead of instaling the docker cli in the container, you could also write a couple lines of code using the docker sdk for the programming language of your choice - but you will need to access the rest-api.
< update>actualy, if you bind the docker.sock into the container, you can query the deails with curl --silent --unix-socket /var/run/docker.sock http://localhost/version | jq '.Platform.Name'. < /update>

If kubectl would provide the server’s platform name, it would be by far the easiest solution. But the only detail about the engine is kubectl get node ${nodename} -o jsonpath="{.status.nodeInfo.containerRuntimeVersion}", which returns docker://19.3.12 (of course with the version of your installed engine).

The least effort and cleanest solution actualy is to pass the value into the container using an ENV.