@@ -17,15 +17,26 @@ DOCKER_TAG=$ORG/$PRJ_NAME
1717CMD_ARGS=( ${@ } )
1818CMD_ARGS=${CMD_ARGS[*]: 1}
1919
20+ RUN_SHELL=/usr/bin/zsh
21+
2022if [[ $2 == :* ]]; then
2123 DOCKER_TAG=$DOCKER_TAG $2
2224 CMD_ARGS=${CMD_ARGS[*]: 2}
25+ elif [ " $2 " = " bash" ]; then
26+ RUN_SHELL=/bin/bash
27+ $RUN_SHELL CMD_ARGS=${CMD_ARGS[*]: 2}
2328fi
2429
2530if [ " $1 " = " build" ]; then
31+ if [ " $RUN_SHELL " = " /bin/bash" ]; then
32+ CMD_ARGS=" $CMD_ARGS --build-arg USE_ZSH=false"
33+ fi
2634 echo " Building a docker image with tagname $DOCKER_TAG and arguments $CMD_ARGS "
2735 docker build . -t $DOCKER_TAG $CMD_ARGS --build-arg UID=` id -u` --build-arg GID=` id -g`
2836elif [ " $1 " = " run" ]; then
37+ if test -f " $HOME /.gitconfig" ; then
38+ CMD_ARGS=" $CMD_ARGS -v $HOME /.gitconfig:/home/user/.gitconfig"
39+ fi
2940 echo " Run a docker image with tagname $DOCKER_TAG and arguments $CMD_ARGS "
3041
3142 docker run -tid --privileged --gpus all \
@@ -36,18 +47,18 @@ elif [ "$1" = "run" ]; then
3647 -v $PWD :/home/user/$PRJ_NAME \
3748 --network host \
3849 $CMD_ARGS \
39- $DOCKER_TAG /bin/bash
50+ $DOCKER_TAG $RUN_SHELL
4051
4152 last_cont_id=$( docker ps -qn 1)
4253 echo $( docker ps -qn 1) > $PWD /.last_exec_cont_id.txt
4354
44- docker exec -ti $last_cont_id /bin/bash
55+ docker exec -ti $last_cont_id $RUN_SHELL
4556elif [ " $1 " = " exec" ]; then
4657 echo " Execute the last docker container"
4758
4859 last_cont_id=$( tail -1 $PWD /.last_exec_cont_id.txt)
4960 docker start ${last_cont_id}
50- docker exec -ti ${last_cont_id} /bin/bash
61+ docker exec -ti ${last_cont_id} $RUN_SHELL
5162else
5263 echo " "
5364 echo " ============= $0 [Usages] ============"
0 commit comments