howtowhale / dvm

Docker Version Manager
https://howtowhale.github.io/dvm/
Apache License 2.0
522 stars 50 forks source link

Query the host for the docker version #138

Closed Fenntasy closed 7 years ago

Fenntasy commented 7 years ago

It would maybe require to maintain a list of client API version but wouldn't it be useful to have a command like dvm use-client 1.22 which would know where to switch?

carolynvs commented 7 years ago

Copied from https://github.com/getcarina/dvm/issues/139#issuecomment-257882854

Halp, I forgot the version The user has a docker host somewhere that was setup months ago and now they don't remember which docker version it has (and they aren't using Carina which provides $DOCKER_VERSION).

  1. Just try to use docker and see if it works or not.
  2. Oops, it didn't work and the error message says that the server is using API version 1.19
  3. Err, I have no clue what I should put into the dvm use command...
  4. Either find that webpage manually mapping the versions, or just play guess and check until they get it right.

What the user really wanted was dvm detect which would hit the docker api (/version) figure out what version their host is using, and update them to the right version of docker transparently.

dvm detect uses the DOCKER_HOST and DOCKER_CERT_PATH variables to connect to the Docker API. Using /version, it gets the docker version from the the Version field in the response (below). It then exports DOCKER_VERSION and executes a dvm use under the covers to update to the right Docker client.

{
     "Version": "1.5.0",
     "Os": "linux",
     "KernelVersion": "3.18.5-tinycore64",
     "GoVersion": "go1.4.1",
     "GitCommit": "a8a31ef",
     "Arch": "amd64",
     "ApiVersion": "1.19"
}
carolynvs commented 7 years ago

@Fenntasy This feature is now in dvm 0.7.0, you can run dvm upgrade to get it. 🍰

$ dvm detect
1.10.3 is not installed. Installing now...
Installing 1.10.3...
Now using Docker 1.10.3