upserve / docker-api

A lightweight Ruby client for the Docker Remote API
MIT License
1.09k stars 287 forks source link

client version 1.16 is too old. Minimum supported API version is 1.24(Windows 2016) #538

Closed lmayorga1980 closed 4 years ago

lmayorga1980 commented 5 years ago

Seems like docker-api is a dependency of inspec and having the following issue with Windows 2016 Docker Host.

inspec exec .\test.rb -t docker://776634aef0bd
Traceback (most recent call last):
        19: from C:/tools/ruby25/bin/inspec:23:in `<main>'
        18: from C:/tools/ruby25/bin/inspec:23:in `load'
        17: from C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/inspec-2.3.5/bin/inspec:12:in `<top (required)>'
        16: from C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor/base.rb:466:in `start'
        15: from C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor.rb:387:in `dispatch'
        14: from C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor/invocation.rb:126:in `invoke_command'
        13: from C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor/command.rb:27:in `run'
        12: from C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/inspec-2.3.5/lib/inspec/cli.rb:181:in `exec'
        11: from C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/inspec-2.3.5/lib/inspec/cli.rb:181:in `new'
        10: from C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/inspec-2.3.5/lib/inspec/runner.rb:58:in `initialize'
         9: from C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/inspec-2.3.5/lib/inspec/runner.rb:66:in `configure_transport'
         8: from C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/inspec-2.3.5/lib/inspec/backend.rb:51:in `create'
         7: from C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/train-1.5.0/lib/train/transports/docker.rb:22:in `connection'
         6: from C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/train-1.5.0/lib/train/transports/docker.rb:41:in `create_new_connection'
         5: from C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/train-1.5.0/lib/train/transports/docker.rb:41:in `new'
         4: from C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/train-1.5.0/lib/train/transports/docker.rb:61:in `initialize'
         3: from C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/docker-api-1.34.2/lib/docker/container.rb:346:in `get'
         2: from C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/docker-api-1.34.2/lib/docker/connection.rb:65:in `block (2 levels) in <class:Connection>'
         1: from C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/docker-api-1.34.2/lib/docker/connection.rb:37:in `request'
C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/docker-api-1.34.2/lib/docker/connection.rb:42:in `rescue in request': client version 1.16 is too old. Minimum supported API version is 1.24, please upgrade your client to a newer version (Docker::Error::ClientError)
PS C:\chocopacks\chocobee\nodejs\6.10.2> [Environment]::GetEnvironmentVariable("DOCKER_URL")
tcp://127.0.0.1:2375
PS C:\chocopacks\chocobee\nodejs\6.10.2> irb
irb(main):001:0> require 'docker'
=> true
irb(main):002:0> Docker.version
Traceback (most recent call last):
        6: from C:/tools/ruby25/bin/irb.cmd:19:in `<main>'
        5: from (irb):2
        4: from C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/docker-api-1.34.2/lib/docker.rb:109:in `version'
        3: from C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/docker-api-1.34.2/lib/docker/connection.rb:65:in `block (2 levels) in <class:Connection>'
        2: from C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/docker-api-1.34.2/lib/docker/connection.rb:37:in `request'
        1: from C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/docker-api-1.34.2/lib/docker/connection.rb:42:in `rescue in request'
Docker::Error::ClientError (client version 1.16 is too old. Minimum supported API version is 1.24, please upgrade your client to a newer version)
irb(main):003:0> ENV['DOCKER_HOST']
=> nil
irb(main):004:0> ENV['DOCKER_URL']
=> "tcp://127.0.0.1:2375"
irb(main):005:0> ENV['DOCKER_API_VERSION']
=> "1.37"
irb(main):006:0>
tlunter commented 5 years ago

@lmayorga1980 Can you try this branch? https://github.com/swipely/docker-api/tree/release-2.x

lmayorga1980 commented 5 years ago

@tlunter , :+1:

lmayorga1980 commented 5 years ago

docker-api-1.34.2 - This is actually the build from that branch but tried to keep compatible with the higher dependency of inspec and train.

Seems like it blows because the container is not running and that is a good sign because it is actually not running :smile:

With Stopped Container

Traceback (most recent call last):
        35: from C:/tools/ruby25/bin/inspec:23:in `<main>'
        34: from C:/tools/ruby25/bin/inspec:23:in `load'
        33: from C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/inspec-2.3.5/bin/inspec:12:in `<top (required)>'
        32: from C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor/base.rb:466:in `start'
        31: from C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor.rb:387:in `dispatch'
        30: from C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor/invocation.rb:126:in `invoke_command'
        29: from C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor/command.rb:27:in `run'
        28: from C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/inspec-2.3.5/lib/inspec/cli.rb:181:in `exec'
        27: from C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/inspec-2.3.5/lib/inspec/cli.rb:181:in `new'
        26: from C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/inspec-2.3.5/lib/inspec/runner.rb:58:in `initialize'
        25: from C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/inspec-2.3.5/lib/inspec/runner.rb:66:in `configure_transport'
        24: from C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/inspec-2.3.5/lib/inspec/backend.rb:51:in `create'
        23: from C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/train-1.5.0/lib/train/transports/docker.rb:22:in `connection'
        22: from C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/train-1.5.0/lib/train/transports/docker.rb:41:in `create_new_connection'
        21: from C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/train-1.5.0/lib/train/transports/docker.rb:41:in `new'
        20: from C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/train-1.5.0/lib/train/transports/docker.rb:64:in `initialize'
        19: from C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/train-1.5.0/lib/train/extras/command_wrapper.rb:128:in `load'
        18: from C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/train-1.5.0/lib/train/plugins/base_connection.rb:95:in `platform'
        17: from C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/train-1.5.0/lib/train/platforms/detect.rb:9:in `scan'
        16: from C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/train-1.5.0/lib/train/platforms/detect/scanner.rb:27:in `scan'
        15: from C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/train-1.5.0/lib/train/platforms/detect/scanner.rb:27:in `each'
        14: from C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/train-1.5.0/lib/train/platforms/detect/scanner.rb:33:in `block in scan'
        13: from C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/train-1.5.0/lib/train/platforms/detect/scanner.rb:45:in `scan_children'
        12: from C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/train-1.5.0/lib/train/platforms/detect/scanner.rb:45:in `each'
        11: from C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/train-1.5.0/lib/train/platforms/detect/scanner.rb:46:in `block in scan_children'
        10: from C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/train-1.5.0/lib/train/platforms/detect/scanner.rb:46:in `instance_eval'
         9: from C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/train-1.5.0/lib/train/platforms/detect/specifications/os.rb:35:in `block in load'
         8: from C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/train-1.5.0/lib/train/platforms/detect/helpers/os_common.rb:43:in `unix_uname_s'
         7: from C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/train-1.5.0/lib/train/platforms/detect/helpers/os_common.rb:36:in `command_output'
         6: from C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/train-1.5.0/lib/train/plugins/base_connection.rb:103:in `run_command'
         5: from C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/train-1.5.0/lib/train/transports/docker.rb:94:in `run_command_via_connection'
         4: from C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/docker-api-1.34.2/lib/docker/container.rb:76:in `exec'
         3: from C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/docker-api-1.34.2/lib/docker/exec.rb:22:in `create'
         2: from C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/docker-api-1.34.2/lib/docker/connection.rb:65:in `block (2 levels) in <class:Connection>'
         1: from C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/docker-api-1.34.2/lib/docker/connection.rb:37:in `request'
C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/docker-api-1.34.2/lib/docker/connection.rb:48:in `rescue in request': {"message":"Container f485568c6490711c046945534d1b74dd9810ff6d35b10584287ff28ebbeb27dd is not running"} (Docker::Error::ConflictError)

With Running Container

I had to set the DOCKER_URL environment variable in order to pick the tcp url.

[Environment]::SetEnvironmentVariable('DOCKER_URL','tcp://127.0.0.1:2375')

PS C:\chocopacks\chocobee\nodejs\6.10.2> inspec exec .\test.rb -t docker://b4f21b9cf2ce
Traceback (most recent call last):
        19: from C:/tools/ruby25/bin/inspec:23:in `<main>'
        18: from C:/tools/ruby25/bin/inspec:23:in `load'
        17: from C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/inspec-2.3.5/bin/inspec:12:in `<top (required)>'
        16: from C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor/base.rb:466:in `start'
        15: from C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor.rb:387:in `dispatch'
        14: from C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor/invocation.rb:126:in `invoke_command'
        13: from C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor/command.rb:27:in `run'
        12: from C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/inspec-2.3.5/lib/inspec/cli.rb:181:in `exec'
        11: from C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/inspec-2.3.5/lib/inspec/cli.rb:181:in `new'
        10: from C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/inspec-2.3.5/lib/inspec/runner.rb:58:in `initialize'
         9: from C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/inspec-2.3.5/lib/inspec/runner.rb:66:in `configure_transport'
         8: from C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/inspec-2.3.5/lib/inspec/backend.rb:51:in `create'
         7: from C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/train-1.5.0/lib/train/transports/docker.rb:22:in `connection'
         6: from C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/train-1.5.0/lib/train/transports/docker.rb:41:in `create_new_connection'
         5: from C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/train-1.5.0/lib/train/transports/docker.rb:41:in `new'
         4: from C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/train-1.5.0/lib/train/transports/docker.rb:64:in `initialize'
         3: from C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/train-1.5.0/lib/train/extras/command_wrapper.rb:128:in `load'
         2: from C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/train-1.5.0/lib/train/plugins/base_connection.rb:95:in `platform'
         1: from C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/train-1.5.0/lib/train/platforms/detect.rb:9:in `scan'
C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/train-1.5.0/lib/train/platforms/detect/scanner.rb:41:in `scan': Sorry, we are unable to detect your platform (Train::PlatformDetectionFailed)
tas50 commented 5 years ago

@tlunter Is there anything the community of users can do to help that 2.x branch along? Here at Chef we rely pretty heavily on this library and I'm sure that some point Docker is going to remove support for the older API it relies on. If there's something we can do to help support newer docker releases do let us know.

frezbo commented 5 years ago

@tlunter Any plans to get the v2branch released?Any blockers?

zenspider commented 4 years ago

Where does this stand?

tlunter commented 4 years ago

I've merged and pushed the v2 branch as v2.0.0.pre.1. Please let know if folks have any issue.