Skip to content
This repository has been archived by the owner on Sep 26, 2021. It is now read-only.

env output is not compatible with windows #732

Closed
ahmetb opened this issue Mar 6, 2015 · 14 comments
Closed

env output is not compatible with windows #732

ahmetb opened this issue Mar 6, 2015 · 14 comments

Comments

@ahmetb
Copy link
Contributor

ahmetb commented Mar 6, 2015

C:\Users\ahmetb>docker-machine env docker-vb
export DOCKER_TLS_VERIFY=yes
export DOCKER_CERT_PATH=C:\Users\ahmetb\.docker\machine\machines\docker-vb
export DOCKER_HOST=tcp://192.168.99.100:2376

export wouldn't work on windows cmd.exe/powershell. We must generate the correct output for cmd/ps and must also keep in mind that user might be running on mingw(msys)/cygwin and in that case this output is already valid (except the cert path though). I may fix this some time, not top priority.

@ehazlett
Copy link
Contributor

ehazlett commented Mar 6, 2015

See #733 (comment) (we currently recommend to install msysgit which has bash).

@sthulb
Copy link
Contributor

sthulb commented Mar 6, 2015

I think in the future, we should support at least powershell

@ehazlett
Copy link
Contributor

ehazlett commented Mar 6, 2015

I agree -- but I defer to @ahmetalpbalkan as he has better domain knowledge than I do.

@StefanScherer
Copy link
Member

I've played with docker-machine.exe on Windows last week. I additionally downloaded docker.exe CLI that is also pre-built on dockerproject.com.

Assuming Chocolatey we can install VirtualBox and curl with two little steps. I have made all these steps in a good old cmd.exe shell:

λ cinst virtualbox
λ cinst curl

Then download docker-machine.exe and docker.exe

λ curl -L -o docker-machine.exe https://github.com/docker/machine/releases/download/v0.1.0/docker-machine_windows-amd64.exe
λ curl -L -o docker.exe https://master.dockerproject.com/windows/amd64/docker.exe

Now create a VirtualBox dev machine:

λ docker-machine create -d virtualbox dev

And here comes my favorite for cmd.exe shells: Translate the unix'ish environments printed by docker-machine and set it as environment variables in a plain Windows shell:

λ for /f "tokens=2" %i in ('docker-machine env dev') do set %i

We are almost up and running. But the docker.exe (nightly build ?) already uses protocol version 1.18, but talking to a docker host we need version 1.17 for docker 1.5.0 hosts.

This could be done with a little trick:

λ sed -ibak -b docker.exe -e 's/1.18/1.17/g'

And now you can do something like

λ docker logs
λ docker images

Maybe this helps.

@ehazlett
Copy link
Contributor

@StefanScherer thanks for the info! i hope to have a "recommended" guide soon so you don't have to jump through all of those hoops!

@tknerr
Copy link

tknerr commented Apr 13, 2015

I'm hopefully waiting for docker 1.6.0 release to support this out of the box.

@StefanScherer awesome info! I got stuck with the different protocol versions, using sed to fix that is nice ;-)

Is it usable like that or do you actually run into protocol incompatibilies quite early for the basic commands?

@ahmetb
Copy link
Contributor Author

ahmetb commented Apr 13, 2015

@tknerr @StefanScherer about the overriding API version, you can +1 the proposal here: moby/moby#11486

@StefanScherer
Copy link
Member

@ahmetalpbalkan I'll have a look at your proposal.
I've tested the output of the current docker-machine.exe v0.2.0-rc3 and found some other issues:

C:\Users\vagrant>for /f "tokens=2" %i in ('docker-machine env dev') do set %i

C:\Users\vagrant>set DOCKER_TLS_VERIFY=1

C:\Users\vagrant>set DOCKER_CERT_PATH="C:\\Users\\vagrant\\.docker\\machine\\machines\\dev"

C:\Users\vagrant>set DOCKER_HOST=tcp://192.168.99.100:2376

C:\Users\vagrant>set Run
Environment variable Run not defined

C:\Users\vagrant>docker-machine env dev
export DOCKER_TLS_VERIFY=1
export DOCKER_CERT_PATH="C:\\Users\\vagrant\\.docker\\machine\\machines\\dev"
export DOCKER_HOST=tcp://192.168.99.100:2376

# Run this command to configure your shell: eval $(docker-machine env dev)


C:\Users\vagrant>docker info
FATA[0000] Couldn't read ca cert "C:\Users\vagrant\.docker\machine\machines\dev"\ca.pem:
open "C:\Users\vagrant\.docker\machine\machines\dev"\ca.pem: The filename, directory name,
or volume label syntax is incorrect.
  1. The "bash" comment # Run this command ... has to be ignored on Windows.
  2. The quotes in the envionment variable seems to make trouble.

After correcting the DOCKER_CERT_PATH environment the docker client can find the cert:

C:\Users\vagrant>set DOCKER_CERT_PATH=C:\Users\vagrant\.docker\machine\machines\dev

C:\Users\vagrant>docker info
FATA[0000] Error response from daemon: client and server don't have same version (client : 1.19, server: 1.17)

So IMHO the docker-machine.exe should be more polite on windows and make it easier to set the environments.

@ahmetb
Copy link
Contributor Author

ahmetb commented Apr 14, 2015

@StefanScherer sorry I didn't get your point.

 set DOCKER_CERT_PATH="C:\\Users\\vagrant\\.docker\\machine\\machines\\dev"

this is not a valid usage for cmd.exe. you should not use backslashes or double quotes.

I recently fixed the same issue b2d-cli for windows: boot2docker/boot2docker-cli#356 I'm hoping to port that here soon.

@StefanScherer
Copy link
Member

@ahmetalpbalkan I've just retried my for loop from three weeks ago. Parsing the current output of docker-machine.exe results in the two errors above. So it gets more complicated for Windows users to use these envs.

I know the output of docker-machine is for unix shells at the moment. It would be fine if docker-machine outputs the correct values without the double quotes and without quotes.

@ahmetb
Copy link
Contributor Author

ahmetb commented Apr 14, 2015

@StefanScherer umm, yes this issue is about that precisely :)

@StefanScherer
Copy link
Member

@ahmetalpbalkan your PR in boot2docker-cli looks promising!

@ehazlett
Copy link
Contributor

@StefanScherer this is a goal for 0.3.0 -- better windows experience. we want to be able to support cmd.exe / powershell out of the box.

@dgageot
Copy link
Member

dgageot commented Jan 13, 2016

Closing. this had been fixed

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants