Skip to content

Instantly share code, notes, and snippets.

@doi-t
Last active July 13, 2019 06:07
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 doi-t/d82bf0fa78a3c099ed17c05bb2670c62 to your computer and use it in GitHub Desktop.
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!
#!/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