# [ANN] OCaml+Opam Images for Docker for Windows

[ANN] OCaml+opam Images for Docker for Windows

Hello all,

I’m glad to announce the availability of OCaml and opam native Windows Container images for Docker for Windows. This is the result of my hard work at Tarides, with precious help from @dra27, @talex5, @avsm, and the rest of the team.

They can be found under the ocaml/opam repository in the Docker Hub. Try them with Docker for Windows! Be sure to switch Docker to Native Windows Containers.

docker run -it ocaml/opam:windows-mingw
docker run -it ocaml/opam:windows-msvc

We provide images for the mingw-w64 (from OCaml 4.02 to 4.12) and the MSVC (from OCaml 4.06 to 4.12) ports. They are based on each release of Windows 10 amd64 currently supported by Microsoft on the Docker Hub. The images use opam 2.0, and we plan to update to opam 2.1 when it’s released. The images also ship a Cygwin installation, Git for Windows, and the winget package manager.

We use @fdopen’s OCaml for Windows distribution and opam-repository fork. As it is getting deprecated at the end of August 2021, we’ll transition to opam 2.1 and the standard opam-repository when that happens.

In order to get the correct environment for any RUN command involving OCaml or opam, prefix the command with

  • ocaml-env exec --64 -- if based on mingw-w64; or
  • ocaml-env exec --64 --ms=vs2019 -- if based on MSVC.

The images are built at https://base-images.ocamllabs.io/, using an OCurrent pipeline that builds Docker images. You can rebuild them yourself using the OCluster set of tools that I have ported to Windows.

We provide a comprehensive set of tags (replace port with either mingw or msvc):

  • windows-port: the latest version of OCaml for each Windows version;
  • windows-port-winver: the latest version of OCaml for Windows 10 winver;
  • windows-port-ocaml-mlver: OCaml version mlver for each Windows version;
  • windows-port-winver-ocaml-mlver: OCaml version mlver for Window 10 winver.

When the Windows version is not specified in the tag, the image is a multiarch image that will work on every supported version of Windows 10. Docker automatically selects the appropriate one based on the host version.

We will be using these images in the upcoming ocaml-ci and opam-repo-ci for Windows.

Further work on these include the transition to opam 2.1, and we’ll provide the Cygwin port of OCaml when it’s fixed upstream and available in the Cygwin package repository.

Happy hacking!

– Antonin


For those curious about the history of this work, @Rucikir began this journey back in 2020 with an internship with @Zimm_i48 and @yurug. That internship helped us discover all the intricacies of what was required for Windows support, and then @Rucikir joined Tarides and has subsequently been hacking away with @dra27 and @talex5 at OCaml Labs (with advice on @djs55 at Docker) during these pandemic months and introducing Windows support into the core OCaml CI stack. This includes a number of fixes to the OCaml compiler itself!

I can’t think of a better showcase for the value of open source development – this has been a wonderful collaborative effort across multiple organisations and countries, and congratulations to @Rucikir on persevering through all the software layers and details to shipping this in the production infrastructure for ocaml.org. And of course, huge thanks to @fdopen for his mingw-opam-repository and @dra27 and @nojb and the core OCaml team for such excellent ongoing support from the compiler itself.

As a community, these regularly built Windows images will form the basis for full opam/OCaml support of Windows. The work being deployed here makes it possible to not only support Windows on a snapshot of our ecosystem, but also to keep Windows support working on an ongoing basis!


I just tried it – nice!

Thanks a lot for this, I can only imagine it must have been painstaking work to get everything working.

Cross-referencing https://discuss.ocaml.org/t/ocaml-for-windows-installation-confusion/ I think these docker images could/should be recommended as THE way to get started under Windows.



If anyone gets the chance to try out the VS Code container extension with these Windows images, that might be a fine thing to add to the recommendation list.

The base images are ~8-10GB in size, so this isn’t a lightweight option, but it is one that should be fairly well integrated with VSCode/Windows 10 for those users who do need to generate Windows executables without cross-compilation.