Created
August 25, 2020 01:55
-
-
Save outro56/f8b60a59ff0aea521d3435767bf20f49 to your computer and use it in GitHub Desktop.
run docker contains with default arguments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dockerx() { | |
if [ "$#" -eq "0" ]; then | |
echo "Usage: dockerx IMAGE [OPTIONS]" | |
return 1 | |
else | |
img=$1 | |
shift | |
# remove invalid characters from the container name | |
name=`echo "$img" | tr /:?\ @ _` | |
cmd="docker run -it --rm --name $name -v $PWD:/workdir -w /workdir $img $@" | |
echo $cmd | |
eval $cmd | |
fi | |
} | |
export -f dockerx >/dev/null | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment