I am trying to setup HashiCorp vault using docker. I am using MySql database for the storage. I created both MySql and Vault docker containers in same network using docker network.
config.hcl
ui = true
storage "mysql" {
address = "localhost:3306"
username = "root"
password = "Test@12345"
database = "vault"
}
listener "tcp" {
address = "127.0.0.1:8200"
tls_disable = "true"
}
MySql Container:
docker run --name vault-mysql -e MYSQL_ROOT_PASSWORD=Test@12345 -d --network vault_network mysql:latest
Vault Container:
docker run -p 8200:8200 -e 'VAULT_LOCAL_CONFIG={"backend": {"file": {"path": "/Users/jaddap2/vault/config.hcl"}}, "default_lease_ttl": "168h", "max_lease_ttl": "720h"}' \
--cap-add=IPC_LOCK --network vault_network vault server
When I try to access the vault using http://127.0.0.1:8200/ui I get the following error
Vault Docker container runs in dev mode by default as per it's Dockerfile.
So, passing server
argument won't make any different. You can simply run just vault
. Then you'll be able to access the UI. But during the dev mode, it runs on memory.
docker run -p 8200:8200 -e 'VAULT_LOCAL_CONFIG={"backend": {"file": {"path": "/tmp/config.hcl"}}, "default_lease_ttl": "168h", "max_lease_ttl": "720h"}' \
--cap-add=IPC_LOCK --network vault_network vault
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With