Challenged to get ServiceStack self-hosted F# example that works on Windows, working on Docker

I created ServiceStack F# projects using Visual Studio 2013 and ServiceStackVS. I then created a “ServiceStack Self Hosted Empty” project using F#. It works.

However, I’m unable to get the project working after ‘containerizing’ it with Docker and attempting to run it under boot2docker. I have a tried-and-tested boot2docker in VirtualBox configuration running on the Windows machine. SSH’ing into boot2docker and using shared folders to access the Windows file system from within boot2docker. The Dockerfile builds successfully:

  • Creating docker images on successful TeamCity build
  • Docker: how do I make a DNS entry for a not yet started container available in another container
  • Using Docker and MongoDB
  • How to compile C code that is using kernel function in docker and use pci device in container?
  • Capturing Dockerfile variable in file
  • Which is the Dockerfile encoding?
  • Dockerfile:

    FROM mono:3.10
    
    RUN apt-get -qq update && apt-get -qqy install unzip socat
    
    ADD . /var/www/
    WORKDIR /var/www/
    
    RUN nuget install SelfHost03/SelfHost03/packages.config -o packages
    RUN xbuild SelfHost03.sln
    
    EXPOSE 8080
    
    CMD /usr/bin/socat -s EXEC:"mono SelfHost03/SelfHost03/bin/Debug/SelfHost03.exe",ignoreeof -,ignoreeof
    

    also tried:

    ENTRYPOINT ["mono","SelfHost03/SelfHost03/bin/Debug/SelfHost03.exe"]
    

    But, when I try to run the container, I receive the following:


    ServiceStack SelfHost listening at http://localhost:8080

    Unhandled Exception:
    System.ComponentModel.Win32Exception: Cannot find the specified file
    at System.Diagnostics.Process.Start_shell (System.Diagnostics.ProcessStartInfo startInfo, System.Diagnostics.Process process) [0x0
    0000] in :0
    at System.Diagnostics.Process.Start_common (System.Diagnostics.ProcessStartInfo startInfo, System.Diagnostics.Process process) [0x
    00000] in :0
    at System.Diagnostics.Process.Start (System.Diagnostics.ProcessStartInfo startInfo) [0x00000] in :0
    at System.Diagnostics.Process.Start (System.String fileName) [0x00000] in :0
    at SelfHost03.Main.main (System.String[] argv) [0x00000] in :0
    [ERROR] FATAL UNHANDLED EXCEPTION: System.ComponentModel.Win32Exception: Cannot find the specified file
    at System.Diagnostics.Process.Start_shell (System.Diagnostics.ProcessStartInfo startInfo, System.Diagnostics.Process process) [0x0
    0000] in :0
    at System.Diagnostics.Process.Start_common (System.Diagnostics.ProcessStartInfo startInfo, System.Diagnostics.Process process) [0x
    00000] in :0
    at System.Diagnostics.Process.Start (System.Diagnostics.ProcessStartInfo startInfo) [0x00000] in :0
    at System.Diagnostics.Process.Start (System.String fileName) [0x00000] in :0
    at SelfHost03.Main.main (System.String[] argv) [0x00000] in :0

  • How to install extension for php via docker-php-ext-install?
  • mariadb docker container on OS X: can't create database directory
  • Connecting to Docker container from host
  • Apache remap to apache within docker container
  • Can't get remote Hazelcast client to connect to cluster running in docker containers
  • executing mysql script docker
  • One Solution collect form web for “Challenged to get ServiceStack self-hosted F# example that works on Windows, working on Docker”

    It took some time which was a result of my lack of familiarity with F# but, the problem arises with the addition/inclusion of:

    Process.Start("http://localhost:8080/") |> ignore
    

    Recreating the C# project using the update templates includes the equivalent:

    Process.Start("http://localhost:8080/");
    

    After removing these statements, the projects will continue to run on Windows and the derived Docker images/containers will work too.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.