Skip to content

Instantly share code, notes, and snippets.

@majgis
Last active May 31, 2018 05:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save majgis/22c55fe389d76f8c04e57b555941e13d to your computer and use it in GitHub Desktop.
Save majgis/22c55fe389d76f8c04e57b555941e13d to your computer and use it in GitHub Desktop.
docker run helper function
# Execute docker run with --rm --network shared
# The shared network will be created if it dosn't already exist
dr () {
docker network inspect shared > /dev/null 2>&1
if [ $? -ne 0 ]
then
docker network create shared > /dev/null 2>&1
fi
local DOCKER_CMD="docker run --rm --network shared $@"
echo
echo "${DOCKER_CMD}"
echo
eval "${DOCKER_CMD}"
}
$ dr -it --name alpinetest alpine ash
docker run --rm --network shared -it --name alpinetest alpine ash
/ #
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment