Skip to content

Instantly share code, notes, and snippets.

@elmariofredo
Last active January 19, 2022 08:42
Show Gist options
  • Save elmariofredo/596163001988be8ed42f060c379ea565 to your computer and use it in GitHub Desktop.
Save elmariofredo/596163001988be8ed42f060c379ea565 to your computer and use it in GitHub Desktop.
Docker run and docker build simplified
#!/bin/bash
if [ -z "$1" ]
then
IMAGE=image
else
IMAGE=$1
fi
WORK_DIR=$(docker image inspect ${IMAGE} --format='{{.Config.WorkingDir}}')
if [ -z "$WORK_DIR" ]
then
WORK_DIR=/workdir
fi
echo docker run -it --rm -v $PWD:$WORK_DIR --entrypoint sh "${IMAGE}"
docker run -it --rm -v $PWD:$WORK_DIR --entrypoint sh "${IMAGE}"
#!/bin/bash
WORK_DIR=$(docker image inspect $1 --format='{{.Config.WorkingDir}}')
if [ -z "$WORK_DIR" ]
then
WORK_DIR=/workdir
fi
docker run -it --rm -v $PWD:$WORK_DIR --entrypoint sh "$1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment