Installing an uptodate version of Mono on Ubuntu using docker

This has been really really painful so far! I just want to get a recent build of Mono into my Ubuntu docker container! It seems the Ubuntu distro is ridiculously out of date and I need to get a recent build on so that I can run a ServiceStack API from it.

Here is my docker file:

  • Is migration from docker to vm possible?
  • Windows cmd docker command piping
  • permission issue for collectstatic in docker-compose
  • How do I get AWS credentials in the AWS ECS docker container?
  • mysql 5.7 can't allow docker IP access on CentOS7
  • Add external plugin to sonarqube
    FROM    ubuntu:14.04
    ADD     . /src
    RUN     cd src
    RUN     sudo bash
    RUN     apt-get -y install git
    RUN     apt-get -y install autoconf
    RUN     apt-get -y install libtool
    RUN     apt-get -y install g++
    RUN     apt-get -y install gettext
    RUN     apt-get -y install make
    RUN     apt-get -y install mono-complete
    RUN     git clone git:// /home/mono
    RUN     cd /home/mono
    RUN     ./ --prefix=/usr/local
    RUN     make
    RUN     make install
    CMD     ["mono", "/build/Web.Api.exe"]

    Rather than building from source I have also tried:

    FROM    ubuntu:14.04
    MAINTAINER wayneo
    ADD     . /src
    RUN     sudo bash
    RUN     apt-get update
    RUN     apt-get -f install
    RUN     apt-get -y -q install wget
    RUN     wget -q -O- | apt-key add -
    RUN     apt-get remove -y --auto-remove wget
    RUN     sh -c "echo 'deb /' >> /etc/apt/sources.list.d/mono-opt.list"
    RUN     apt-get -q update
    RUN     apt-get -y -q install mono-opt
    CMD     ["/opt/mono/bin/mono", "/src/build/Web.Api.exe"]

    Which also does not work!

    Has anyone managed to do this? Surely it should be easier than this?

  • How to enable authentication on MongoDB through Docker?
  • How can I share a network interface with docker without setns error?
  • Docker compose: is it possible to mount a local file to a remote daemon?
  • How to create a Docker container of an AngularJS app?
  • Connect to docker containers with just service name and task slot?
  • Docker to store an application(service) logs in a folder and purge them on a timely basis
  • One Solution collect form web for “Installing an uptodate version of Mono on Ubuntu using docker”

    There are a few things here which seem a bit “odd” to me.

    First of all, you RUN a sudo bash (to change user you should use the USER instruction). From the start of your container you will have root access so you do not need to do this.

    On each RUN command you will spawn a new container for that layer, I recommend you make all your apt-get commands one line like so (although this is not too important):

    RUN apt-get -y install git autoconf libtool g++ gettext make mono-complete

    (as you’re running apt-get install from a non interactive environment, I recommend you also set ENV DEBIAN_FRONTEND noninteractive so you don’t get any prompts.)

    It’s likely that with your Ubuntu version the apt sources will be out of date. Just to make sure you can download all your packages correctly I recommend before you do this you run an update before apt-get install.

    RUN apt-get update

    As mentioned above, each “layer” of the Dockerfile creates a new container, so using cd in RUN wont work. You should use the WORKDIR instruction instead to have:

    WORKDIR /home/mono

    Each step may produce an error when you run docker build. You should check the output when you build.

    With all this in mind I have managed to build mono from Git and it seems to execute. The Dockerfile to get to this point is below (I have taken out your ADD and CMD, be sure to add them). I recommend you check out the Dockerfile reference at

    Once you have built the container, you can go into bash (at least with the Ubuntu base) by running docker run -t -i <IMAGE ID> /bin/bash. The image ID will be shown as Successfully built <ID HERE>. From here you can debug why your image isn’t working correctly.

    Lastly it may be worth building FROM an existing image which has Mono installed. If you wanted to build from for example, you’d do

    FROM thaiphan/mono

    Rather than ubuntu. You can then also ADD your own files and add your own CMD.

    Dockerfile I made from yours with Mono:

    FROM    ubuntu:14.04
    ENV DEBIAN_FRONTEND noninteractive
    RUN apt-get update
    RUN apt-get -y install git autoconf libtool g++ gettext make mono-complete
    RUN git clone git:// /home/mono
    WORKDIR /home/mono
    RUN ./ --prefix=/usr/local
    RUN make && make install
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.