The previous post talked about the FIWARE project in general. This post will describe how to setup a virtual machine using Docker.
The FIWARE technical ecosystems (consisting eg. of the FIWARE Lab and Cloud) has little to offer on backend storage facilities. Thankfully, as being based on OpenStack, a developer should be fairly free to to set up anything up to the hearts content, as long as it fits into a virtual machine. Given that FIWARE supports Docker, I choose to go that route.
FIWARE, Docker and virtual machines
The Docker ecosystem provides docker-machine, a cloud orchestration solution. In order to manage virtual machines and to provision services into that virtual machine, a local installation of docker is required. Additionally, docker-machine helps to get Docker up and running on a remote cloud environment.
Besides the rather terse documentation on Docker on FIWARE, there are also a couple of slides which are quite helpful. Unfortunately I ran into issues which gave me a hard time. Hopefully they will be helpful and protect you from running into the same problems as I did:
- The documentation says to set up a custom security group. This didn’t worked for me. Any other security group but “default” was not accepted when running docker-machine and resulted in docker-machine to fail when creating the VM. Instead of creating a custom security group I changed default to suit the needs as described.
- Although the documentation gives the impression that access to arbitrary ports can be configured, this was not the case for me. Ports 2376 (required by Docker), 3376 (required by docker-compose) and the ranges 32768-33768 were simply not available, despite being specified in the security group port settings. I had to additionally contact the nodes support team to request opening of these ports, which was granted after briefly describing what they are needed for.
- Once docker-machine instantiates a VM, it will also provision docker into that VM. docker-machine will use the user “root” for that, but the VM images provided by my node don’t allow root access for good reasons. Thankfully docker-machine provides the switch openstack-ssh-user which I had to supply additionally to the documentation.
After setting the adapted environment variables, I had success to get my VM on FIWARE up and running with this command line:
docker-machine create -d openstack --openstack-flavor-id="3" --openstack-image-id=69a06c08-10e0-4eb9-a5ef-347871c904fd --openstack-net-name="node-int-net-02" --openstack-floatingip-pool="public-ext-net-02" --openstack-sec-groups="default" --openstack-ssh-user=ubuntu fiware-postgres
Instead of specifying the image name on which the VM will be based on, I used the images ID. You get the ID after login to https://cloud.lab.fiware.org/#nova/images/, selecting the image you intend to base your VM on and right-clicking on the image to get more details. It chose to use Ubuntu 14.04 LTS.
You also have to adapt the values for flavor-id (the “sizing” of the computing instance which has been granted to you/which you requested) and openstack-net-name, openstack-floatingip-pool. Additionally the images I based by VM on did not allow ssh root access for which I had to instruct docker-machine to use another user name to provision Docker into the VM using the switch –openstack-ssh-user=ubuntu. The last parameter fiware-postgres is the name of your virtual machine, chose a fitting <VMNAME> name.
Be patient. Issuing the command to set up the VM until completion took about five minutes. You can test if everything went fine by running
If you get an output like
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS fiware-postgres - openstack Running tcp://188.8.131.52:2376 v1.9.1
(note STATE Running) you successfully set up your first VM on FIWARE. The last step before you can start installing docker services into your VM is to update your VM with the latest security patches. Connect to your VM with
docker-machine ssh <VMNAME>
and update with
sudo apt-get update && sudo apt-get upgrade