Skip to content

Instantly share code, notes, and snippets.

@petehunt
Last active August 1, 2021 21:30
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 petehunt/bb2eca02b43fcf61a52178dea83f475e to your computer and use it in GitHub Desktop.
Save petehunt/bb2eca02b43fcf61a52178dea83f475e to your computer and use it in GitHub Desktop.
Create a fresh Ubuntu instance tied to your current working directory
#!/bin/bash
set -euo pipefail
CONTAINER="$(pwd | sha256sum | awk '{print $1}')"
if docker inspect "$CONTAINER" 2> /dev/null > /dev/null;
then
docker start "$CONTAINER" -ai
else
docker run --name="$CONTAINER" -v $(pwd):/root -w /root -ti ubuntu bash
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment