origin: 'oc cluster up --docker-machine=x' not working in Docker Toolbox (Windows): "cannot obtain a client for Docker machine"

It appears that the --docker-machine option to the oc command doesn’t work in Windows, at least when using Docker Toolbox. This means that --create-machine also fails.

Version
Client:
 Version:      1.12.0
 API version:  1.24
 Go version:   go1.6.3
 Git commit:   8eab29e
 Built:        Thu Jul 28 23:54:00 2016
 OS/Arch:      windows/amd64

Server:
 Version:      1.12.1
 API version:  1.24
 Go version:   go1.6.3
 Git commit:   23cf638
 Built:        Thu Aug 18 17:52:38 2016
 OS/Arch:      linux/amd64

oc v1.3.0
kubernetes v1.3.0+52492b4
features: Basic-Auth
Steps To Reproduce
  1. Use a machine with Windows 10 Home installed (the “Home” version shouldn’t really be required, but users with this version of Windows are the most likely case to be running Docker Toolbox because Home doesn’t have Hyper-V required by Docker for Windows)
  2. Install Docker Toolbox v1.12.0
  3. Copy oc.exe from openshift-origin-client-tools-v1.3.0-3ab7af3d097b57f933eccef684a714f2368804e7-windows.zip into a directory in the PATH.
  4. Launch “Docker Quickstart Terminal” from the start menu
  5. Run oc cluster up --version=v1.3.0 --create-machine which fails with “cannot obtain a client for Docker machine”
  6. Run docker-machine ls and observe that the machine “openshift” was actually created.
  7. Now try oc cluster up --version=v1.3.0 --docker-machine=openshift which also fails with the same error.
  8. Use --loglevel=10 with that last command for a better sense of what’s going on.
Current Result

This first case can be expected to fail because it will try to use the virtualbox docker machine called ‘default’ which is not configured correctly for kubernates:

Robert@crimson  ~
$ oc cluster up --version=v1.3.0
-- Checking OpenShift client ... OK
-- Checking Docker client ... OK
-- Checking Docker version ... OK
-- Checking for existing OpenShift container ... OK
-- Checking for openshift/origin:v1.3.0 image ...
   Pulling image openshift/origin:v1.3.0
   Pulled 1/3 layers, 37% complete
   Pulled 1/3 layers, 55% complete
   Pulled 1/3 layers, 72% complete
   Pulled 2/3 layers, 88% complete
   Pulled 3/3 layers, 100% complete
   Extracting
   Image pull complete
-- Checking Docker daemon configuration ... FAIL
   Error: did not detect an --insecure-registry argument on the Docker daemon
   Solution:

     Ensure that the Docker daemon is running with the following argument:
        --insecure-registry 172.30.0.0/16

     You can run this command with --create-machine to create a machine with the
     right argument.

But if I decide to just let it create a new machine, this happens:

Robert@crimson  ~
$ oc cluster up --version=v1.3.0 --create-machine
-- Checking OpenShift client ... OK
-- Create Docker machine ...
   Creating docker-machine openshift
-- Checking Docker client ... FAIL
   Error: cannot obtain a client for Docker machine "openshift"
   Solution:

     Ensure that the Docker machine is available and running. You can also create a
     new Docker machine by specifying the --create-machine flag.

   Caused By:
     Error: could not get Docker client for machine openshift
     Caused By:
       Error: invalid endpoint

The new machine was created and it exists:

$ docker-machine ls
NAME        ACTIVE   DRIVER       STATE     URL                         SWARM   DOCKER    ERRORS
default     *        virtualbox   Running   tcp://192.168.99.100:2376           v1.12.1
openshift   -        virtualbox   Running   tcp://192.168.99.101:2376           v1.12.1
Expected Result
-- Server Information ...

   OpenShift server started.
   The server is accessible via web console at:
       https://192.168.99.101:8443

etc.

Additional Information
Robert@crimson  ~
$ oc cluster up --version=v1.3.0 --docker-machine=openshift --loglevel=10
-- Checking OpenShift client ...
-- Checking Docker client ...
I1008 18:38:24.315667   28264 up.go:380] Getting client for Docker machine "openshift"
I1008 18:38:24.317168   28264 cmd.go:58] Executing local command:
I1008 18:38:24.317168   28264 cmd.go:59]   docker-machine.exe
I1008 18:38:24.317168   28264 cmd.go:61]   ip
I1008 18:38:24.317168   28264 cmd.go:61]   openshift
I1008 18:38:24.658408   28264 cmd.go:81] Stdout:
192.168.99.101
I1008 18:38:24.658909   28264 cmd.go:58] Executing local command:
I1008 18:38:24.658909   28264 cmd.go:59]   docker-machine.exe
I1008 18:38:24.658909   28264 cmd.go:61]   env
I1008 18:38:24.658909   28264 cmd.go:61]   openshift
I1008 18:38:25.056261   28264 cmd.go:81] Stdout:
export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://192.168.99.101:2376"
export DOCKER_CERT_PATH="C:\Users\Robert\.docker\machine\machines\openshift"
export DOCKER_MACHINE_NAME="openshift"
# Run this command to configure your shell:
# eval $(docker-machine.exe env openshift)
FAIL
   Error: cannot obtain a client for Docker machine "openshift"
   Solution:

     Ensure that the Docker machine is available and running. You can also create a
     new Docker machine by specifying the --create-machine flag.

   Caused By:
     Error: could not get Docker client for machine openshift
     Caused By:
       Error: invalid endpoint

It appears that the environment variable settings from this command:

$ docker-machine env openshift
export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://192.168.99.101:2376"
export DOCKER_CERT_PATH="C:\Users\Robert\.docker\machine\machines\openshift"
export DOCKER_MACHINE_NAME="openshift"
# Run this command to configure your shell:
# eval $("C:\Program Files\Docker Toolbox\docker-machine.exe" env openshift)

Aren’t actually making it into the environment. If I manually run eval $(docker-machine env openshift) then I get the correct environment variables set and a simple oc cluster up --version=v1.3.0 works.

So it appears that it’s the --docker-machine option to the oc command that isn’t working. This means --create-machine also fails since it uses the same code to point everything at the new docker machine.

Here’s the full sequence of commands that work around this problem:

Robert@crimson  ~
$ docker-machine ls
NAME      ACTIVE   DRIVER       STATE     URL                         SWARM   DOCKER    ERRORS
default   *        virtualbox   Running   tcp://192.168.99.100:2376           v1.12.1

Robert@crimson  ~
$ oc cluster up --version=v1.3.0 --create-machine
-- Checking OpenShift client ... OK
-- Create Docker machine ...
   Creating docker-machine openshift
-- Checking Docker client ... FAIL
   Error: cannot obtain a client for Docker machine "openshift"
   Solution:

     Ensure that the Docker machine is available and running. You can also create a
     new Docker machine by specifying the --create-machine flag.

   Caused By:
     Error: could not get Docker client for machine openshift
     Caused By:
       Error: invalid endpoint

Robert@crimson  ~
$ docker-machine ls
NAME        ACTIVE   DRIVER       STATE     URL                         SWARM   DOCKER    ERRORS
default     *        virtualbox   Running   tcp://192.168.99.100:2376           v1.12.1
openshift   -        virtualbox   Running   tcp://192.168.99.102:2376           v1.12.1

Robert@crimson  ~
$ eval $(docker-machine env openshift)

Robert@crimson  ~
$ oc cluster up --version=v1.3.0
-- Checking OpenShift client ... OK
-- Checking Docker client ... OK
-- Checking Docker version ... OK
-- Checking for existing OpenShift container ... OK
-- Checking for openshift/origin:v1.3.0 image ...
   Pulling image openshift/origin:v1.3.0
   Pulled 0/3 layers, 3% complete
   Pulled 0/3 layers, 16% complete
   Pulled 0/3 layers, 30% complete
   Pulled 0/3 layers, 44% complete
   Pulled 1/3 layers, 62% complete
   Pulled 1/3 layers, 74% complete
   Pulled 2/3 layers, 87% complete
   Pulled 2/3 layers, 97% complete
   Pulled 3/3 layers, 100% complete
   Extracting
   Image pull complete
-- Checking Docker daemon configuration ... OK
-- Checking for available ports ... OK
-- Checking type of volume mount ...
   Using Docker shared volumes for OpenShift volumes
-- Creating host directories ... OK
-- Finding server IP ...
   Using 192.168.99.102 as the server IP
-- Starting OpenShift container ...
   Creating initial OpenShift configuration
   Starting OpenShift using container 'origin'
   Waiting for API server to start listening
   OpenShift server started
-- Installing registry ... OK
-- Installing router ... OK
-- Importing image streams ... OK
-- Importing templates ... OK
-- Login to server ... OK
-- Creating initial project "myproject" ... OK
-- Server Information ...
   OpenShift server started.
   The server is accessible via web console at:
       https://192.168.99.102:8443

   You are logged in as:
       User:     developer
       Password: developer

   To login as administrator:
       oc login -u system:admin


Robert@crimson  ~
$

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 16 (10 by maintainers)

Most upvoted comments

Same issue just with newer Docker Toolbox(17.05.0-ce) and Virtualbox(5.1.22) on Windows 10. I was able to workaround with ‘eval $(docker-machine env openshift)’.

oc cluster up --host-config-dir=$PWD/openshift.local.config --host-data-dir=$PWD/data --use-existing-config --docker-machine=openshift --loglevel=20
-- Checking OpenShift client ...
-- Checking Docker client ...
I0616 14:37:53.353186   11132 up.go:502] Getting client for Docker machine "openshift"
I0616 14:37:53.355128   11132 cmd.go:58] Executing local command:
I0616 14:37:53.355128   11132 cmd.go:59]   docker-machine.exe
I0616 14:37:53.355128   11132 cmd.go:61]   ip
I0616 14:37:53.355128   11132 cmd.go:61]   openshift
I0616 14:37:53.691574   11132 cmd.go:81] Stdout:
192.168.99.100
I0616 14:37:53.691574   11132 cmd.go:58] Executing local command:
I0616 14:37:53.691574   11132 cmd.go:59]   docker-machine.exe
I0616 14:37:53.691574   11132 cmd.go:61]   env
I0616 14:37:53.691574   11132 cmd.go:61]   openshift
I0616 14:37:54.074869   11132 cmd.go:81] Stdout:
export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://192.168.99.100:2376"
export DOCKER_CERT_PATH="C:\Users\ayen\.docker\machine\machines\openshift"
export DOCKER_MACHINE_NAME="openshift"
export COMPOSE_CONVERT_WINDOWS_PATHS="true"
# Run this command to configure your shell:
# eval $(docker-machine.exe env openshift)
FAIL
   Error: cannot obtain a client for Docker machine "openshift"
   Solution:

     Ensure that the Docker machine is available and running. You can also create a
     new Docker machine by specifying the --create-machine flag.

   Caused By:
     Error: could not get Docker client for machine openshift
     Caused By:
       Error: invalid endpoint
$ oc version
oc v1.5.1+7b451fc
kubernetes v1.5.2+43a9be4
features: Basic-Auth

Server https://192.168.99.100:8443
openshift v1.5.1+7b451fc
kubernetes v1.5.2+43a9be4