start_docker 813 Bytes
Newer Older
1 2 3
#!/bin/bash

AMDIS_IMAGE="mathiwr/amdis-1.1.dev:debian9"
4 5
HOME_DIR="/Volumes/home/${USER}"
USER_ID="$(id -u)"
6 7 8 9 10 11 12 13 14

echo "-- pull docker image ${AMDIS_IMAGE}"
docker pull ${AMDIS_IMAGE}

if [ ! -f Dockerfile.${USER} ]; then
  cat >Dockerfile.${USER} << EOF
FROM ${AMDIS_IMAGE}

USER root
15
RUN useradd --home-dir /home/${USER} --uid ${USER_ID} -U -M ${USER}
16 17

USER ${USER}
18 19
ENV HOME /home/${USER}
WORKDIR /home/${USER}
20 21 22 23 24 25 26
EOF

  echo "-- create new docker image for current user"
  docker build -t amdis-1.1.dev:${USER} -f Dockerfile.${USER} .
fi

echo "-- run docker image and mount two directories into the container"
27 28
echo "  1. ${PWD} -> /amdis_workshop"
echo "  2. ${HOME_DIR} -> /home/${USER}"
29

30 31 32
docker run -it --rm -u ${USER} \
  -v ${PWD}:/amdis_workshop \
  -v ${HOME_DIR}:/home/${USER} \
33 34
  amdis-1.1.dev:${USER} bash