Docker - Almost Everything I Could Want, But Not What I Need

TLDR; I ended up not using Docker.

I needed to give a Linux development version of the Hydrological Simulation Program - FORTRAN (HSPF) to a Windows user. Found Docker and it looked about perfect, worked fine as a container on Linux, but really doesn’t work as close to seamlessly as I need on Windows.

I developed a new docker container called timcera/hspf with a containerized version of Hydrological Simulation Program FORTRAN.

My ‘Dockerfile’:

FROM centos:6.6

RUN yum update -y && \
    yum install -y \
        cmake \
        gcc-gfortran ; \
    yum clean all ; \
    mkdir /home/hspf ; \
    mkdir /home/hspf/libatc_dev ; \
    mkdir /home/hspf/libatc_dev_build ; \
    mkdir /home/hspf/hspf_dev ; \
    mkdir /home/hspf/hspf_dev_build

# Copy the source code into the container
COPY libatc_dev/ /home/hspf/libatc_dev
COPY hspf_dev/ /home/hspf/hspf_dev

# Required so the hspf executable can find libatc
ENV LD_LIBRARY_PATH /usr/local/lib

# Make and install libatc first
WORKDIR /home/hspf/libatc_dev_build
RUN cmake \
    -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_INSTALL_PREFIX=/usr/local \
    ../libatc_dev && \
    make && \
    make install && \
    make clean

# The hspf cmake must find libatc already installed
WORKDIR /home/hspf/hspf_dev_build
RUN cmake \
    -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_INSTALL_PREFIX=/usr/local \
    ../hspf_dev && \
    make && \
    make install && \
    make clean

WORKDIR /home/hspf

ENTRYPOINT ["hspf"]

Some things to note:

  • I used ‘cmake’ and that worked well within the container.

  • The container does one thing, run ‘hspf’.

On Linux just run:

sudo docker build .

Then a changed to a directory with the required input files and ran:

sudo docker run -v /path/to/input/files:/home/hspf timcera/hspf input.uci

And it worked! I thought, this is good, I can write a DOS batch file so that the user would just type ‘lhspf.bat input.uci’ and Bob’s your uncle. Well, I was wrong to think that it would be straightforward on Windows.

To start with, the comparable process to the Linux version above DOES NOT WORK:

sudo docker run -v /c/path/to/input/files:/home/hspf timcera/hspf input.uci

Gives an error since for some inane reason the ‘/c’ is replaced behind the scenes with ‘C:’. The docker program sees ‘C:/path/to/input/files:/home/tcera’ which obviously can’t work since the ‘:’ is the mount path separator and can only be used once in the string.

There are proposed solutions to this problem:

http://blog.tutum.co/2014/11/05/how-to-use-docker-on-windows/

Too complex…

  1. Install cifs-utils:

    wget http://distro.ibiblio.org/tinycorelinux/5.x/x86/tcz/cifs-utils.tcz
    
    tce-load -i cifs-utils.tcz
    
  2. Create folder:

    mkdir /mnt/sharefolder
    
  3. Mount shared folder - blog says to use sudo, but that doesn’t work.:

    mount -t cifs //WINDOWS_IP/shared /mnt/sharefolder -o username=WINDOWS_USERNAME
    

If I could write a DOS batch file to make it all happen, maybe then one of the other solutions might make sense, but why does it have to be that way? How about the separator in the -v argument be something that can’t be used in ANY of the supported file systems. Maybe an @ symbol? Heck, the lowly ‘,’ might work and would be better than using a ‘:’.

So… In the end I just figured out how to compile the whole thing on Windows using gfortran.

Comments

comments powered by Disqus