Installing Docker on Windows and Cygwin

Posted on Wednesday, April 5, 2017






I am going to do an install of docker on Windows and set it up to be easily accessible via cygwin commands.

In this install I will be using the official Docker Toolbox https://www.docker.com/products/docker-toolbox [1] .  This will install a local virtual machine to help





Installation





Download the Windows version of Docker Toolbox.





After it downloads run the installer





Click Run




For me I am not a fan of sending feedback from my system so I uncheck this and click next.






Click Next





Checkbox git for Windows and click next






Click Next.





Click Install






While installing I got this prompt.  Click Install.




Another one, click Install






A third one, click Install





Finish

Now for some setup





Setup





On your desktop there should now be a Docker Quickstart terminal.  Run it.

This will create a virtual machine in VirtualBox and install docker in it.  This is where docker will actually run.




See its doing stuff.








You should get here, an interactive terminal

I can run docker stuff from here…. But I don't wanna I want to use cygwin.

To do that I first need to grab some environmental variables from this interactive terminal.

Run this command.


  > docker-machine env





You could copy the export portion of this and put it your .bash_profile file and then you could talk to your docker machine and run docker images from cygwin.

But there is one potential problem… Your docker host IP could change from reboot to reboot.   To deal with this I run this cmd


  > eval $(docker-machine env default)




Now you can run commands like


  > docker ps






  > docker run hello-world





Its working but I am getting this little weird cert error There is a thread on it over here https://github.com/docker/for-win/issues/422 [2] but no solution at this point





How best to set it up?


If you reboot your machine and open up the Oracle-VirtualBox



You will see that the docker server is not running.


For me, for my purposes this is how I want to keep it.  To not have the docker server start on a reboot of my machine.



With that in mind if I want to start docker I need to run the Docker-Quickstart Terminal app whenever I want to use docker and I have not yet started the virtual machine that runs docker in Oracle Virtual Box




Also to make my life easier in cygwin I made this alias that will set the env variables



  > vi ~/.bash_profile


And append this to the end


 alias startdocker='eval $(docker-machine env default)'





Now just run startdocker in a terminal


  > startdocker
  > docker run hello-world





That is good enough for me for now J




References


[1]        Docker Toolbox
[2]        Docker Toolbox issue on windows





1 comment:

  1. Thanks a lot for the article! Very useful :)

    ReplyDelete