Running Unison in Docker

Unison publishes a Docker Image containing the Unison Codebase Manager, which can be used to:

  • Give unison a try without having to install it locally
  • Run a (possibly compiled) Unison program in a container
  • Run the local UI for a codebase
  • Experiment with running unison programs under the native runtime.

Running UCM in docker against a local codebase

If you have your codebase in ~/.unison. You could run the following command to start the UCM in a container:

docker run  -it --rm -v ~/.unison:/codebase -p 5757:5757 -p 8080:8080 unisonlang/unison

In this command:

  • -p 5757:5757 makes the LSP server available
  • -p 8080:8008 makes the local UI available so that you can point a browser at http://127.0.0.1:8080/public/ui/. To view the local ui, or run ui within UCM to get a link directly to a project/branch in the ui.
  • -v ~/.unison:/codebase mounts your local codebase to the container. if you omit this part, you'll get a UCM that is looking at the empty codebase in the container located in /codebase.

Running a Unison program in a container

You can run a Unison program in a docker container either by compiling it to a .uc file and running the program with run.compiled or by adding the codebase to the container, and running the program with run

Running a program from a codebase

If you have a codebase in ~/.unison and a program named program in the main branch of the hello project

  docker run --rm -v ~/.unison:/codebase unisonlang/unison:latest run hello/main:.program`

Running a compiled program

👋
NOTE: You must run a compiled unison program (''.uc'') using the same version of ucm that compiled it!

If you have a compiled program named ./program.uc:

  docker run --rm -v ./program.uc:/program.uc unisonlang/unison:latest run.compiled /program.uc

Or you can create a Dockerfile which will create a docker image with your compiled program:

  FROM unisonlang/unison:0.5.29
  COPY program.uc /program.uc
  CMD ["run.compiled", "/program.uc"]