how to check docker version whether it community or enterprise in linux container 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.