vault-init is a useful container that can be used to automatically configure a vault server.
vault-init performs the following operations:
- Check the current vault status (with a retry mechanism that will retry to connect every 5s if the vault server is not available)
- Initialize the vault server (or just unseal and then exit if already initialized)
- Unseal the vault server and save the unseal key
- Create the admin policy
- Create the admin user (username:
$VAULT_ADMIN_USERNAME
and password:$VAULT_ADMIN_PASSWORD
)
You can configure the vault-init behaviour using these env variables:
VAULT_ENDPOINT
is the endpoint of the vault server (eg.https://vault.example.com:8200
)VAULT_ADMIN_PASSWORD
is the desired password for the admin userVAULT_ADMIN_USERNAME
is the desired username for the admin userVAULT_UNSEAL_KEY_PATH
is the path for unseal key saving
- Make sure the Docker daemon is up and running
- Run
npm start
ornpm run start-with-build
to execute vault server and vault-init containers - Run
npm stop
to stop all the running containers
src/
folder contains all the vault-init code (Dockerfile, docker-entrypoint.sh and other configuration files)vault/
folder contains the vault configuration (src/
directory) and persistence data (data/
directory)
In order to push the docker container image to dockerhub you can run
$ npm run publish