Using Docker and the HaLVM

Erlend Hamberg edited this page Dec 14, 2016 · 2 revisions

So, you want to develop with the HaLVM, and you want to use Docker. Great! This can make a lot of sense, and make a lot of things easier. However, there is one thing you should think about before you begin:

Am I trying to develop HaLVMs, or am I trying to develop and test HaLVMs?

With Docker, we are providing a very convenient way to do the former, but not do the latter. Because the HaLVM requires Xen, you will not be able to run any of the virtual machines you build using Docker. You will be able to write them, build them, and test them. You can also just use Docker as a convenient way to run HaLVM builds on platforms that wouldn't normally support them (Windows, OS X, etc.), by using invocations like docker run halvm/extended halvm-cabal install.

But, again, you won't be able to run what you create without transferring the created binary to another machine. In the case of the HaLVM, this might mean transferring the binary to a machine that does run Xen, including Xen-enabled VMs or Amazon's EC2.

Yup, that's what I want. How do I make it happen?

Starting a Docker VM with the HaLVM is as simple as picking the version of the HaLVM you want, and using all your standard Docker commands. For example, you could:

docker run -it halvm/extended zsh

And work inside a nice, standardized environment for build HaLVMs. You could also combine Docker with HaLVM sandboxes:

docker run halvm/extended halvm-cabal sandbox init

to create a HaLVM sandbox in the current directory, and then

docker run halvm/extended halvm-cabal install

to build and install the HaLVM locally.

What versions of the HaLVM are supported?

Roughly speaking, there is a three dimensional grid specifying versions of the HaLVM you can get from Docker:

  • base vs extended. Base versions contain only the base libraries built by the core HaLVM, while extended versions include a number of very handy networking and crypto libraries. Unless you really want to roll your own, we strongly recommend newcomers choose extended.
  • integer-gmp vs integer-simple. GMP versions of the HaLVM use Haskell's integer-gmp library. Doing so means that we link directly to the GMP math library, which is much faster than the alternative but creates GPL entanglements for any generated HaLVM.
  • The underlying OS the image is built on.

In a desperate attempt to limit complexity, we separate versions by name for the first two, and by tag for the last item. So, for example, the full docker name for a version of the HaLVM might be base-gmp:fedora23. The default tag (:latest, in Docker parlance) will point to whatever OS we're doing our primary development on.

For the other two axes, please see the following grid:

Base Extended
GMP halvm/base-gmp halvm/extended-gmp
Simple halvm/base halvm/extended

So, to run an interactive shell on the integer-simple version of the extended set, you'd run:

docker run -it halvm/extended zsh

You can also see all the images, and their related tags and Dockerfiles, at the HaLVM Docker Hub page.

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.