Commit 0365b2e6 authored by Timo Koch's avatar Timo Koch
Browse files

Add Dockerfile and runscript for release 2.12

parent e141b7b1
Pipeline #1047 failed with stages
......@@ -17,6 +17,16 @@ Run
docker run -it --rm --env DISPLAY=unix$DISPLAY --device /dev/dri --volume /tmp/.X11-unix:/tmp/.X11-unix:rw dumux:latest /bin/bash
Running a DuMux Docker container with the script
In the folder dumux/release-2.12 you are going to find a script called `dumux` that spins up the container when you run
./dumux open
Running with docker-compose
# DuMuX docker container (version release 2.12)
# see for information on the base image
# It is Ubuntu LTS customized for better Docker compatibility
FROM phusion/baseimage:0.9.22
# run Ubuntu update as advised on
RUN apt-get update \
&& apt-get upgrade -y -o Dpkg::Options::="--force-confold" \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# install the basic dependencies
RUN apt-get update \
&& apt-get install --no-install-recommends --yes \
ca-certificates \
vim \
python-dev \
python-pip \
git \
pkg-config \
build-essential \
gfortran \
cmake \
mpi-default-bin \
mpi-default-dev \
libsuitesparse-dev \
libsuperlu-dev \
libeigen3-dev \
doxygen \
paraview \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# add the permission helper script to the my_init service
COPY /etc/my_init.d/
# create a dumux user
# add the welcome message (copied further down) output to bashrc
# make the set permission helper script executable
# add user to video group which enables graphics if desired
RUN useradd -m --home-dir /dumux dumux \
&& echo "cat /dumux/WELCOME" >> /dumux/.bashrc \
&& chmod +x /etc/my_init.d/ \
&& usermod -a -G video dumux
# Turn off verbose syslog messages as described here:
RUN touch /etc/service/syslog-forwarder/down
# switch to the dumux user and set the working directory
USER dumux
WORKDIR /dumux
# create a shared volume communicating with the host
RUN mkdir /dumux/shared
VOLUME /dumux/shared
# This is the message printed on entry
# clone dune dependencies
RUN git clone -b releases/2.5 && \
git clone -b releases/2.5 && \
git clone -b releases/2.5 && \
git clone -b releases/2.5 && \
git clone -b releases/2.5 && \
git clone -b releases/2.5 && \
git clone -b releases/2.5 && \
git clone -b releases/2.5
# clone dumux repository
RUN git clone -b releases/2.12
# configure module
RUN /dumux/dune-common/bin/dunecontrol --opts=/dumux/dumux/optim.opts all
# build doxygen documentation
RUN cd dumux/build-cmake && make doc
# switch back to root
USER root
# make graphical output with paraview work
# set entry point like advised
# this sets the permissions right, see above
ENTRYPOINT ["/sbin/my_init","--quiet","--","/sbin/setuser","dumux","/bin/bash","-l","-c"]
# start interactive shell
CMD ["/bin/bash","-i"]
Welcome to the dumux Docker container (version 2.12). You compile and run test / examples
in the folder build-cmake/test.
Copying the output like VTK files to the folder /dumux/shared will make them available
outside this container on the host for display.
This docker container also has graphics support on Linux systems.
#!/usr/bin/env bash
# the image name
# the host directory that is mounted into...
# ...this container directory.
executeandlog ()
echo "[$@]"
eval $@
help ()
echo ""
echo "Usage: dumux <command> [options]"
echo ""
echo " dumux open [image] - open a DuMuX Docker container."
echo " dumux help - display this message."
echo ""
echo "Optionally supply an Docker image name to the open command."
echo ""
# open the dumux container. Only argument is the Docker image.
COMMAND="docker create -i -t \
-e HOST_UID=$(id -u $USER) \
-e HOST_GID=$(id -g $USER) \
--device /dev/dri \
-v /tmp/.X11-unix:/tmp/.X11-unix:rw \
--name dumux \
$IMAGE /bin/bash"
CONTAINER_NAME=$(executeandlog $COMMAND | tail -n 1)
executeandlog docker start -a -i $CONTAINER_NAME
executeandlog docker rm $CONTAINER_NAME
# Check if user specified valid command otherwise print help message
if [ "$1" == "open" ]; then
open $IMAGE
exit 1
# The user can pass the user and group id by passing
# --env HOST_UID=$(id -u $USER) --env HOST_GID=$(id -g $USER)
# with the UID on the host to the container. Should work for Linux, Mac and Windows.
# Allows to manage the writes for shared volumes.
if [ "$HOST_UID" ]; then
usermod -u $HOST_UID dumux
if [ "$HOST_GID" ]; then
groupmod -g $HOST_GID dumux
# Make sure that everything in /dumux is accessible by the dumux user
# sed "1d" removes first line which is the folder itself
# exclude the shared folder using grep. This folder should be accessible by setting the UID/GID.
# chown transfers ownership to group dumux user dumux
# the OR true trick avoids the script exiting due to use of set -e
find /dumux -maxdepth 1 | sed "1d" | grep -v "/dumux/shared" | xargs chown -R dumux:dumux 2> /dev/null || true
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment