hashicorp / docker-vault

Official Docker images for Vault
Mozilla Public License 2.0
500 stars 223 forks source link

HELP!! "Error parsing listener configuration" and "Error initializing listener of type tcp: listen tcp4 0.0.0.0:3201: bind: address already in use" #332

Open absta opened 1 year ago

absta commented 1 year ago

Hi, I've been tearing my hair out trying to figure why I keep getting these errors.

The odd this is, if I use the same configuration and pass it in via the command line using VAULT_LOCAL_CONFIG then everything works!

NOTE: This is without having a config.hcl file in /vault/config

This is an example of me passing in the config docker run --cap-add=IPC_LOCK -e 'VAULT_LOCAL_CONFIG={"storage":{"postgresql":{"connection_url":"postgres://vault:examplePwd@host.docker.internal:5432/hc-vault?sslmode=disable"}}, "listener": [{"tcp": { "address": "0.0.0.0:8200", "tls_cert_file": "/vault/config/certs/vault.crt", "tls_key_file": "/vault/config/certs/vault.key"}}], "default_lease_ttl": "168h", "max_lease_ttl": "720h", "ui": true}' --network acuk-net --name vault-server -v ~/vault/config:/vault/config -p 8200:8200 hashicorp/vault server

This gives the following output image

However, if I try to spin up the container using the following config file

storage "postgresql" {
  connection_url = "postgres://vault:examplePwd@host.docker.internal:5432/hc-vault?sslmode=disable"
}

listener "tcp" {
  address = "0.0.0.0:8200"
  tls_disable = 0
  tls_cert_file = "/vault/config/certs/vault.crt"
  tls_key_file  = "/vault/config/certs/vault.key"
}
api_addr = "https://vault.sbx.local:3200"
ui = true

using the following docker run command `docker run --cap-add=IPC_LOCK -p 8200:8200 -v ~/vault/config:/vault/config --network acuk-net --name vault-server hashicorp/vault server -config=/vault/config/config.hcl

I get this???? image

Can't figure out what I'm doing wrong!!

It's defo not a port issue, because the first method of spinning up the container works just fine...

The super weird thing is, if I use the config file (above) this way, it works!! docker run --cap-add=IPC_LOCK -e 'VAULT_LOCAL_CONFIG={"default_lease_ttl": "168h", "max_lease_ttl": "720h", "ui": true}' --network acuk-net --name vault-server -v ~/vault/config:/vault/config -p 8200:8200 hashicorp/vault server

image