鈫怺34mINFO鈫怺0m[0000] Creating SSH key...
鈫怺34mINFO鈫怺0m[0002] Creating VirtualBox VM...
鈫怺34mINFO鈫怺0m[0025] Starting VirtualBox VM...
鈫怺34mINFO鈫怺0m[0030] Waiting for VM to start...
鈫怺34mINFO鈫怺0m[0066] "docker-vb" has been created and is now the active machine.
鈫怺34mINFO鈫怺0m[0066] To point your Docker client at it, run this in your shell: $(docker-machine env docker-vb)
the last line doesn't make much sense as cmd.exe/powershell won't support it. We must find the windows equivalent (can't tell from off the top of my head) or tell people what to do instead.
Thanks! I think, for now at least, we recommend that users install msysgit which gives them bash I believe and this works. I agree with you we need to get to supporting cmd.exe/powershell at some point.
@ehazlett I am hoping to help with that in the long term. I wasn't aware of msysgit recommendation since I haven't seen it in the docs https://docs.docker.com/machine/
@ahmetalpbalkan ugh well then it was removed from the readme. It was in there at one point. I'll get it back. Thanks!
and thanks for helping! it is greatly appreciated!
The console on windows bothers me. Perhaps we can have console adapters, especially one for windows.
Perhaps depending on the parent process docker-machine.exe
could show a different hint for the user.
For a cmd.exe
this does the trick:
To point your Docker client at it, run this in your shell: for /f "tokens=2" %i in ('docker-machine env docker-vb') do set %i
There should be a similar solution running from a powershell, but I haven't tried it yet.
There are still bunch of weird ssh-keygen/openssl bugs with mingw/cygwin installations and almost nobody can get it working right at this point. Telling people to just use set x=y
(on cmd.exe) or $env:x=y
(on ps) is probably fair enough at this point.
@ahmetalpbalkan perhaps we could brainstorm the best way to support windows clients? I would like to get a "recommended" path for windows users (shell, env, etc).
@ehazlett definitely, if this works out of the box on cmd.exe or msys very easily, that'd be nice.
I'd be keen to help with powershell support - right now I have a powershell function that parses the export lines and sets variables accordingly, but it's not a good solution - I'd much rather docker-machine recognised it was in powershell and actually set the variables for me.
@silarsis I recently tackled this problem in boot2docker shellinit: https://github.com/boot2docker/boot2docker-cli/pull/356
Unfortunately there is no way to find out if we are running on cmd or powershell. (Unless we do win32 api calls and try to find name of parent process, which is very hacky).
However we were able to support this for powershell:
boot2docker shellinit | Invoke-Expression
Because I couldnt find an easy way to eval things in cmd.exe and I decided making powershell output the only stdout is good enough.
I don't even mind if there's no automatic recognition - docker-machine env --powershell
would be fine.
I'm new to powershell - is it possible to set env variables in a sub-process, or is that restricted the same way bash is? I ask because I'm wondering if the docker-machine env | Invoke-Expression
pattern is appropriate, or if docker-machine can just set the variables and be done with it...?
I don't know PowerShell at all. At this point, I'd settle for something that works exactly like Boot2Docker for Windows with Client Hyper-V replacing VirtualBox. If that's not possible, I'll probably end up rolling my own.
On a Windows system, you have three mutually exclusive options:
You can only pick one, and right now, the second option is the only one that works.
@silarsis setting environment variables in sub-processes doesn't due to the way operating systems work, probably not specific to bash or powershell. :) Piping it to Invoke-Expression
seems like a good way to go.
@znmeb (1) probably won't work (2) is what we have today (3) only ships in Windows Professional SKUs and is not enabled by default. And (2)-(3) cannot coexist on the same machine (i.e. you can't use VBox while Hyper-V is enabled). Today we have machine drivers for Hyper-V and VirtualBox and I believe both works just fine on windows and I'm not sure how all these are relevant to the shellinit discussion here? :smile:
@silarsis also, I liked the idea of something like shellinit --shellname
. Not only we can do best effort when the argument is omitted (esp. on posix), we can print cleaner output for ps
and cmd
cases.
+1 for shellinit --<shellname>
. Seeing this in other places too and seems pretty intuitive. If <shellname>
is omitted one could still default to auto-detecing / guessing
+1 for env --shellname
as well and auto-detecting if missing.
@ehazlett just remembered you were asking me about this on IRC. did you write code for it or should I submit a PR?
@ahmetalpbalkan PR - https://github.com/docker/machine/pull/1033 -- would love your feedback :)
_nevermind_ - will confirm with newer build.
ehazlett I see PR #1033 is merged, but it only addresses powershell. I still see the 'bash'-oriented suggestion with standard Windows cmd.exe.
@ewindisch is SHELL or TERM set in your windows console? If so that's gonna print bash output.
I think this should be pretty well-rounded now, but please open a new issue if there are unexpected workflow consequences.
for /f "tokens=2" %i in ('docker-machine env docker-vb') do set %i
The command above (suggested by https://github.com/docker/machine/issues/733#issuecomment-84394185) works for me, but I also get these two errors:
> set Run
Environment variable Run not defined
> set FOR
Environment variable FOR not defined
@jmauerhan The docker-machine
0.6.0 binary shows a little different command if you just run docker-machine env docker-vb
from a CMD.exe shell.
FOR /f "tokens=*" %i IN ('"docker-machine.exe" env dev') DO %i
This "executes" the REM comment lines without an error.
Most helpful comment
@jmauerhan The
docker-machine
0.6.0 binary shows a little different command if you just rundocker-machine env docker-vb
from a CMD.exe shell.This "executes" the REM comment lines without an error.