Docker Machine provides a nice experience for remotely provisioning and managing instances of Docker. Though Skytap doesn’t currently support a native driver for Docker Machine it doesn’t mean you’re left out in the cold. The generic driver for Docker Machine works great with Skytap!
There are multiple ways to connect to VMs within Skytap. SRA, for example, is a slick HTML 5 app for grabbing terminal access from the browser. However, I like to drive from my local machine, so for this exercise, I set up a jump box, host-1, in a Skytap environment, and exposed port 22 through a Skytap published service. This allows me to ssh into the jump box from my local machine. I could also attach a VPN to my Skytap environment which would allow me to access it from within my corporate network. Both Skytap’s published services and VPNs are great capabilities for seamlessly accessing resources in the Skytap cloud.
I created a second Skytap environment with a single VM, host-2 and connected the networks of the two environments using Skytap’s ICNR feature. This allows each of the VMs to talk to one another. Both VMs were running a clean instance of Ubuntu 14.04 but any OS supported by Docker can be used. The setup looks like this:
Here is the networking configuration for both hosts.
With my environments created and the networking configured, I was ready to roll. From my local machine, I ssh’d in to host-1 to install Docker Engine and Docker Machine. To do this, I used the address information for the published service on host-1. Skytap takes care of all the routing between the public-facing end point and the VM.
MBP-djones:~ djones$ ssh -p <port #> email@example.com firstname.lastname@example.org's password: <password> Welcome to Ubuntu 14.04 LTS (GNU/Linux 3.16.0-55-generic x86_64) * Documentation: https://help.ubuntu.com/ System information as of Wed Dec 16 09:44:19 PST 2015 System load: 0.09 Processes: 83 Usage of /: 7.2% of 18.32GB Users logged in: 0 Memory usage: 6% IP address for eth0: 10.0.0.1 Swap usage: 0% Last login: Wed Dec 16 09:44:19 2015 from 22.214.171.124
I followed the installation guides for Docker Engine and Docker Machine. With these installed on host-1, I could now use Docker Machine to provision Docker Engine on host-2 and create containers. As mentioned earlier, I used the generic driver for Docker Machine which is described in more detail here. Because I was okay with performing a vanilla install of Docker Engine, I only had to provide the IP address for host-2 and a name for the instance, which I left as host-2. What’s great about Docker Machine is that you can control how the Docker Engine is configured on the target machine. Take a look at the Docker Machine create command for more information on which options can be controlled.
root@host-1:~# docker-machine create -d generic --generic-ip-address 10.0.4.1 host-2 Creating CA: /root/.docker/machine/certs/ca.pem Creating client certificate: /root/.docker/machine/certs/cert.pem Running pre-create checks... Creating machine... Waiting for machine to be running, this may take a few minutes... Machine is running, waiting for SSH to be available... Detecting operating system of created instance... Provisioning created instance... Copying certs to the local machine directory... Copying certs to the remote machine... Setting Docker configuration on the remote daemon... To see how to connect Docker to this machine, run: docker-machine env host-2
Docker Machine did its magic: it connected to host-2 and installed Docker Engine. Once it completed, I listed all the instances Docker Machine knows about, which in my case was just the newly created instance on host-2.
root@host-1:~# docker-machine ls NAME ACTIVE DRIVER STATE URL SWARM host-2 - generic Running tcp://10.0.4.1:2376
With the Docker Client and Engine successfully installed on host-2, I set host-2 as the active instance and relisted the machines.
root@host-1:~# eval $(docker-machine env host-2) root@host-1:~# docker-machine ls NAME ACTIVE DRIVER STATE URL SWARM host-2 * generic Running tcp://10.0.4.1:2376
The * in the ACTIVE column identifies host-2 as the active instance and any docker commands issued would be executed on host-2. The command docker-machine active can also be used to check the active instance. With host-2 as my active instance, I ran the hello-world image from Docker Hub to verify the installation.
root@host-1:~# docker run hello-world Unable to find image 'hello-world:latest' locally latest: Pulling from library/hello-world b901d36b6f2f: Pull complete 0a6ba66e537a: Pull complete Digest: sha256:8be990ef2aeb16dbcb9271ddfe2610fa6658d13f6dfb8bc72074cc1ca36966a7 Status: Downloaded newer image for hello-world:latest Hello from Docker. This message shows that your installation appears to be working correctly. To generate this message, Docker took the following steps: 1. The Docker client contacted the Docker daemon. 2. The Docker daemon pulled the "hello-world" image from the Docker Hub. 3. The Docker daemon created a new container from that image which runs the executable that produces the output you are currently reading. 4. The Docker daemon streamed that output to the Docker client, which sent it to your terminal. To try something more ambitious, you can run an Ubuntu container with: $ docker run -it ubuntu bash Share images, automate workflows, and more with a free Docker Hub account: https://hub.docker.com For more examples and ideas, visit: https://docs.docker.com/userguide/
The image was downloaded from Docker Hub, the container was created and run, and I got the output I was expecting.
With this setup, I can configure and manage additional VMs in Environment 2 or, using Skytap ICNR, I can connect my Docker Machine environment to another Skytap environment where I want to manage Docker.
Check out the Skytap Docker Template, or build your own on the host template of your own choosing!