Machine lets you create Docker hosts on your computer, on cloud providers, and inside your own data center. It creates servers, installs Docker on them, then configures the Docker client to talk to them. You basically don't have to have anything installed on your machine prior to this. Which is a hell lot easier, than having to manually install boot2docker before. So, let's try this out.
You want to have at least one thing in place before starting with anything Docker or Machine. Go and get Git for Windows (aka msysgit). It has all kinds of helpful unix tools in his belly, which you need anyway.
Prerequisites - The One For All Solution
The first is to install the windows boot2docker distribution which I showed in an earlier blog. It contains the following bits configured and ready for you to use:
- Docker Windows Client
Prerequisites- The Bits And Pieces
I dislike the boot2docker installer for a variety of reasons. Mostly, because I want to know what exactly is going on on my machine. So I played around a bit and here is the bits and pieces installer if you decide against the one-for-all solution. Start with the virtualization solution. We need something like that on Windows, because it just can't run Linux and this is what Docker is based on. At least for now. So, get VirtualBox and ensure that version 4.3.18 is correctly installed on your system (VirtualBox-4.3.18-96516-Win.exe, 105 MB). WARNING: There is a strange issue, when you run Windows itself in Virtualbox. You might run into an issue with starting the host.
And while you're at it, go and get the Docker Windows Client. The other is to grab the final from the test servers as a direct download (docker-1.6.0.exe, x86_64, 7.5MB). Rename to "docker" and put it into a folder of your choice (I assume it will be c:\docker\. Now you also need to download Docker Machine, which is another single executable (docker-machine_windows-amd64.exe, 11.5MB). Rename to "docker-machine" and put it into the same folder. Now add this folder to your PATH:
If you change your standard PATH environment variable, this might safe your from a lot of typing. That's it. Now you're ready to create your first Machine managed Docker Host.
Create Your Docker Host With Machine
All you need is a simple command:
And the output should state:
docker-machine create --driver virtualbox dev
←[34mINFO←[0m Creating SSH key... ←[34mINFO←[0m Creating VirtualBox VM... ←[34mINFO←[0m Starting VirtualBox VM... ←[34mINFO←[0m Waiting for VM to start... ←[34mINFO←[0m "dev" has been created and is now the active machine. ←[34mINFO←[0m To point your Docker client at it, run this in your shell: eval "$(docker-machine.exe env dev)"This means, you just created a Docker Host using the VirtualBox provider and the name “dev”. Now you need to find out on which IP address the host is running.
If you want to configure your environment variables, needed by the client more easy, just use the following command:
docker-machine ip 192.168.99.102
Which outputs the Linux version of environment variable definition. All you have to do is to change the "export" keyword to "set", remove the " and the double back-slashes and you are ready to go.
docker-machine env dev export DOCKER_TLS_VERIFY=1 export DOCKER_CERT_PATH="C:\\Users\\markus\\.docker\\machine\\machines\\dev" export DOCKER_HOST=tcp://192.168.99.102:2376
C:\Users\markus\Downloads>set DOCKER_TLS_VERIFY=1 C:\Users\markus\Downloads>set DOCKER_CERT_PATH=C:\Users\markus\.docker\machine\machines\dev C:\Users\markus\Downloads>set DOCKER_HOST=tcp://192.168.99.102:2376
Time to test our Docker Client
And here we go now run WildFly on your freshly created host:
Watch the container being downloaded and check, that it is running by redirecting your browser to http://192.168.99.102:8080/.
docker run -it -p 8080:8080 jboss/wildfly
Congratulations on having setup your very first docker host with Maschine on Windows.