meltwater/docker-cleanup

Wrong Docker version on host

Closed this issue · 9 comments

oli-g commented

Hi, I wanted to use this useful tool on a EC2 instance running the last CoreOS stable AMI (version 835.11.0, ami-7e72c70d).

The thing is that it comes with Docker 1.8.3:

 ~ $ docker version
Client:
 Version:      1.8.3
 API version:  1.20
 Go version:   go1.4.2
 Git commit:   cedd534-dirty
 Built:        Fri Jan 22 06:07:01 UTC 2016
 OS/Arch:      linux/amd64

Server:
 Version:      1.8.3
 API version:  1.20
 Go version:   go1.4.2
 Git commit:   cedd534-dirty
 Built:        Fri Jan 22 06:07:01 UTC 2016
 OS/Arch:      linux/amd64

When I try to run docker-cleanup with docker run -v /var/run/docker.sock:/var/run/docker.sock:rw -v /var/lib/docker:/var/lib/docker:rw meltwater/docker-cleanup:latest, I get:

Error response from daemon: client is newer than server (client API version: 1.21, server API version: 1.20)
Cannot run docker binary at /usr/bin/docker
Please check if the docker binary is mounted correctly

Is there a way to use an older version of docker-cleanup that runs the same version of my host? Do you have any suggestion?

Isn't this a common issue? I don't think that all the people is using Docker 1.9.
Thanks a lot!

I believe we should simply update the embedded docker version to be 1.9.1 (or latest)

oli-g commented

@mikljohansson But this is the problem actually: my host has Docker 1.8.3, but docker-cleanup comes with 1.9.1 (from Alpine repo): in my case, I would need version 1.8.3 inside the container too.

Same here, AWS ECS a bit outdated (or as some people call it: "stable") ;-)

@mikljohansson I was thinking there are 2 options :

  • would it make sense to build docker-cleanup for multiple versions of docker. The tag would then look like docker-cleanup:- e.g.
docker::run_instance:
  'cleanup':
    image: 'meltwater/docker-cleanup:1.8.3-1.5.2'
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock:rw"
      - "/var/lib/docker:/var/lib/docker:rw"
  • second option would be to pass an env DOCKER_VERSION and install that specific docker version at runtime.

@salimane I'm thinking there's a 3rd option

  • Rewrite docker-cleanup to use Golang and one of the Golang Docker Daemon API clients and talk to the docker directly from the program. Hopefully this avoids the nasty exact protocol match the docker command line client insists on. We're aren't using any fancy features of the Docker Daemon API so should be fine.

Keeping all the env vars compatible should ensure no one notice a difference if we did such a rewrite.

We'd also need to avoid using the golang:onbuild base image because of its horrible bloatiness. Travis could build the binary and then package it into an image and push that to Docker Hub. Rather than having docker hub build the image directly which forces use of golang:onbuild since the hub only supports dockerized builds.

But otherwise I'd say it makes more sense to try and use some sort of tagging scheme that includes the Docker version, or Docker API version like you suggest and with extra tags for the people that just want the latest version. E.g.

1.5.2-1.10.0
1.5.2-1.9.1
1.5.2-1.8.3
1.5.2 -> 1.5.2-1.10.0
latest -> 1.5.2

Having same issue here: Error response from daemon: client is newer than server (client API version: 1.21, server API version: 1.19) (launching with fleet)

Crazy idea but couldn't the docker client just be mounted from the host? Something like -v $(which docker):/usr/bin/docker

edit: oops, apparently that won't work : binocarlos/powerstrip-weave#8

Ended up forking the dockerfile to use docker v1.7.1, here it is if anyone else needs it: https://github.com/olalonde/docker-cleanup .. would still be nice if it was officially supported through tags here.

As of Docker 1.10, there is now support for the DOCKER_API_VERSION environment variable that allows you to dictate which API version that the client should use.

Alpine linux currently only has 1.9.1 available, but the edge branch currently includes 1.11.1.