Update .bashrc_docker for CentOS usage

resolve invalid option error and able to find nsenter automatically if it has been installed with path notified
pull/57/head
milhu 2015-05-08 11:21:02 +08:00
parent 1d864385af
commit 8e976258b5
1 changed files with 6 additions and 2 deletions

View File

@ -7,11 +7,15 @@ alias docker-ip="sudo docker inspect --format '{{ .NetworkSettings.IPAddress }}'
#the implementation refs from https://github.com/jpetazzo/nsenter/blob/master/docker-enter #the implementation refs from https://github.com/jpetazzo/nsenter/blob/master/docker-enter
function docker-enter() { function docker-enter() {
if [ -e $(dirname "$0")/nsenter ]; then #if [ -e $(dirname "$0")/nsenter ]; then
#Change for centos bash running
if [ -e $(dirname '$0')/nsenter ]; then
# with boot2docker, nsenter is not in the PATH but it is in the same folder # with boot2docker, nsenter is not in the PATH but it is in the same folder
NSENTER=$(dirname "$0")/nsenter NSENTER=$(dirname "$0")/nsenter
else else
NSENTER=nsenter # if nsenter has already been installed with path notified, here will be clarified
NSENTER=$(which nsenter)
#NSENTER=nsenter
fi fi
[ -z "$NSENTER" ] && echo "WARN Cannot find nsenter" && return [ -z "$NSENTER" ] && echo "WARN Cannot find nsenter" && return