Last active
July 13, 2019 06:07
-
-
Save doi-t/d82bf0fa78a3c099ed17c05bb2670c62 to your computer and use it in GitHub Desktop.
Give me a linux environment with the current working directory right now!
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
#!/bin/bash | |
set -ex | |
IMAGE=${1:-ubuntu} | |
if [ ${IMAGE} = 'golang' ]; then | |
TARGET=/go | |
else | |
TARGET=/app | |
fi | |
docker pull ${IMAGE}:latest | |
cat <<-EOF | |
Commands you might need: | |
$ docker rm $$(docker ps -aq) # Cleanup exitted containers | |
$ docker exec -it dev_${IMAGE} /bin/bash # Login to a running container | |
EOF | |
docker run \ | |
-it \ | |
--name dev_${IMAGE} \ | |
--mount type=bind,source="$(pwd)",target=${TARGET} \ | |
${IMAGE}:latest \ | |
/bin/bash # Expect IMAGE includes '/bin/bash' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment