View open merge request
Commits (3)
# InterPore short course docker container
# see https://github.com/phusion/baseimage-docker for information on the base image
# It is Ubuntu LTS customized for better Docker compatibility
FROM phusion/baseimage:0.11
MAINTAINER sina.ackermann@iws.uni-stuttgart.de
# run Ubuntu update as advised on https://github.com/phusion/baseimage-docker
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/*
# add Atom package
RUN curl -sL https://packagecloud.io/AtomEditor/atom/gpgkey | apt-key add - \
&& sh -c 'echo "deb [arch=amd64] https://packagecloud.io/AtomEditor/atom/any/ any main" > /etc/apt/sources.list.d/atom.list'
# install the basic dependencies
# install the basic dependencies
RUN apt-get update \
&& apt-get install --no-install-recommends --yes \
ca-certificates \
vim \
python-dev \
python-pip \
paraview \
gnuplot \
wget \
git \
pkg-config \
build-essential \
gfortran \
cmake \
mpi-default-bin \
mpi-default-dev \
libsuitesparse-dev \
libsuperlu-dev \
libeigen3-dev \
doxygen \
bash-completion \
nano \
atom \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# add the permission helper script to the my_init service
COPY ./setpermissions.sh /etc/my_init.d/setpermissions.sh
# create a dumux-course 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-course dumux-course \
&& echo "cat /dumux-course/WELCOME" >> /dumux-course/.bashrc \
&& chmod +x /etc/my_init.d/setpermissions.sh \
&& usermod -a -G video dumux-course
# copy the extracted dumux-course module and make dumux-course own it
COPY . /dumux-course
RUN chown -R dumux-course:dumux-course /dumux-course
# switch to the dumux user and set the working directory
USER dumux-course
WORKDIR /dumux-course
# create a shared volume communicating with the host
RUN mkdir /dumux-course/shared
VOLUME /dumux-course/shared
# install dumux course dependencies
RUN /dumux-course/install.sh
# switch back to root
USER root
# make graphical output with paraview work
# set entry point like advised https://github.com/phusion/baseimage-docker
# this sets the permissions right, see above
ENTRYPOINT ["/sbin/my_init","--quiet","--","/sbin/setuser","dumux-course","/bin/bash","-l","-c"]
# start interactive shell
CMD ["/bin/bash","-i"]
* Docker
* Linux: ...
* Windows: ...
* MacOS: ...
Setting up a docker container for the dumux-course module
The following steps are necessary to set up the docker container:
* Create a new folder and change into it
* Download the container startup script (dumux-course/scripts/set-up-docker)
* Make it executable
* Open the startup script
For Linux, you can copy and paste the following lines:
mkdir dumux-course
cd dumux-course
wget https://git.iws.uni-stuttgart.de/dumux-repositories/dumux-course/tree/master/scripts/set-up-docker
chmod +x set-up-docker
The first time this will download the latest image.
This may take a while depending on your internet conncetion.
After the download finished the container will spin up.
Type `exit` if you want to close the docker container.
#!/usr/bin/env bash
# get dumux-course install script
wget https://git.iws.uni-stuttgart.de/dumux-repositories/dumux-course/raw/master/scripts/install.sh
chmod +x install.sh
# get necessary docker files
wget https://git.iws.uni-stuttgart.de/dumux-repositories/dumux-course/raw/master/scripts/docker/Dockerfile
wget https://git.iws.uni-stuttgart.de/dumux-repositories/dumux-course/raw/master/scripts/setpermissions.sh
# build docker container
docker build -t dumux-course .
# run docker container
docker run -it --env HOST_UID=$(id -u $USER) --env HOST_GID=$(id -g $USER) --env DISPLAY=unix$DISPLAY --device /dev/dri --volume /tmp/.X11-unix:/tmp/.X11-unix:rw --volume $(pwd):/home/dumux-course/shared --name dumux-course dumux-course /bin/bash
# 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-course
if [ "$HOST_GID" ]; then
groupmod -g $HOST_GID dumux-course
# Make sure that everything in /dumux-course is accessible by the dumux-course 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-course/shared" | xargs chown -R dumux-course:dumux-course 2> /dev/null || true