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:

  • Docker mysql cant connect to container
  • Docker mongodb config file
  • run docker on overlay network failed
  • Docker container can't see a serialport device
  • Use tc to throttle Docker container's outgoing network bandwidth
  • docker compose not linking correctly
    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?

  • Using Nginx as micro service API gateway
  • Why is it required to run the true command when you create a data-only container in Docker?
  • Docker: Benefit of the “From”-Instructions?
  • slow pg_restore on docker container startup
  • Way to delete the images from Private Docker Registry
  • docker cannot start service from DockFile
  • 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.