Created
August 4, 2025 13:12
-
-
Save michaelkosir/271bb6eb94a64e24173bfca7383e4f6a to your computer and use it in GitHub Desktop.
Quickly deploy Vault development servers locally using Docker
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
# Usage: | |
# vdev | |
# vdev 1.20 | |
# vdev 1.19-ent | |
# vdev 1.17.5-ent.hsm.fips1402 | |
# vdev chrome | |
# vdev stop | |
vdev() { | |
pattern='^[0-9]+\.[0-9]+(\.[0-9]+)?(-rc\d)?(-ent)?(\.hsm)?(\.fips1402)?$' | |
if [[ -z $1 || $1 =~ $pattern ]]; then | |
# environment variables | |
export VAULT_ADDR='http://localhost:8200' | |
export VAULT_TOKEN='root' | |
# check if Vault is not running | |
if [ -z "$(docker ps -qf name=vault)" ]; then | |
echo "Starting Vault development server..." | |
version=${1:-latest} | |
if [[ $version == *"-ent"* ]]; then | |
image="hashicorp/vault-enterprise:$version" | |
else | |
image="hashicorp/vault:$version" | |
fi | |
if [[ ! -f ~/.hashicorp/vault.hclic ]]; then | |
touch ~/.hashicorp/vault.hclic | |
fi | |
docker run \ | |
--rm \ | |
--detach \ | |
--name=vault \ | |
--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 | |
echo "Started Vault development server..." | |
fi | |
elif [[ $1 == "stop" ]]; then | |
# environment variables | |
unset VAULT_ADDR | |
unset VAULT_TOKEN | |
# if running, stop Vault | |
if [ "$(docker ps -qf name=vault)" ]; then | |
echo "Stopping Vault development server..." | |
docker stop vault | |
echo "Stopped Vault development server..." | |
fi | |
elif [[ $1 == "chrome" ]]; then | |
open -a "Google Chrome" http://localhost:8200 | |
else | |
echo "Usage: vdev [version] | chrome | stop" | |
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 chrome" | |
echo " vdev stop" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment