Skip to content

Instantly share code, notes, and snippets.

@michaelkosir
Last active October 14, 2025 15:24
Show Gist options
  • Select an option

  • Save michaelkosir/271bb6eb94a64e24173bfca7383e4f6a to your computer and use it in GitHub Desktop.

Select an option

Save michaelkosir/271bb6eb94a64e24173bfca7383e4f6a to your computer and use it in GitHub Desktop.
Quickly deploy Vault development servers locally using Docker
# Usage:
# vdev
# vdev 1.20
# vdev 1.19-ent
# vdev 1.17.5-ent.hsm.fips1402
# vdev list
# vdev list 1.20
# vdev stop
vdev() {
pattern='^[0-9]+\.[0-9]+(\.[0-9]+)?(-rc\d)?(-ent)?(\.hsm)?(\.fips1402)?$'
if [[ -z $1 || $1 =~ $pattern ]]; then
export VAULT_ADDR='http://localhost:8200'
export VAULT_TOKEN='root'
if [ -z "$(docker ps -qf name=vdev)" ]; then
version=${1:-latest}
image="hashicorp/vault:$version"
if [[ $version == *"-ent"* ]]; then
image="hashicorp/vault-enterprise:$version"
fi
if [[ ! -f ~/.hashicorp/vault.hclic ]]; then
touch ~/.hashicorp/vault.hclic
fi
if [[ ! "$(docker images -q $image)" ]]; then
echo "πŸ—οΈ Preparing Development Environment for $image"
docker pull $image | awk '{print "| " $0}'
fi
echo "πŸš€ Starting dev server"
docker run \
--rm \
--detach \
--name=vdev \
--cap-add=IPC_LOCK \
--publish=8200:8200 \
--net=bridge \
--env='VAULT_DEV_LISTEN_ADDRESS=0.0.0.0:8200' \
--env='VAULT_DEV_ROOT_TOKEN_ID=root' \
--env="VAULT_LICENSE=$(cat ~/.hashicorp/vault.hclic)" \
$image server -dev -dev-no-kv > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "❌ Failed to start Vault dev server."
return 1
fi
echo "βœ… Vault dev server started!"
echo " Address: \033[36mhttp://localhost:8200\033[0m"
echo " Token: \033[33mroot\033[0m"
fi
elif [[ $1 == "stop" ]]; then
unset VAULT_ADDR
unset VAULT_TOKEN
if [ "$(docker ps -qf name=vdev)" ]; then
docker stop vdev > /dev/null 2>&1
fi
elif [[ $1 == "list" ]]; then
if [[ -n $2 ]]; then
VERSIONS=($(curl -s https://releases.hashicorp.com/vault | grep -o '/vault/[^/]\+/' | sed 's|/vault/\(.*\)/|\1|' | grep $2))
else
VERSIONS=($(curl -s https://releases.hashicorp.com/vault | grep -o '/vault/[^/]\+/' | sed 's|/vault/\(.*\)/|\1|'))
fi
REVERSED_VERSIONS=()
for (( i=${#VERSIONS[@]}-1; i>=0; i-- )); do
REVERSED_VERSIONS+=("${VERSIONS[i]}")
done
(IFS=$'\n'; printf "%s" "${REVERSED_VERSIONS[*]}")
else
echo "Usage: vdev [version] | stop | list [filter]"
echo "Version format: <major>.<minor>[.<patch>][-rc<release>][-ent][.hsm][.fips1402]"
echo "Examples:"
echo " vdev"
echo " vdev 1.19-ent"
echo " vdev 1.17.5-ent.hsm.fips1402"
echo " vdev list"
echo " vdev list 1.20"
echo " vdev stop"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment