docker-compose给出了“错误从vault.json加载配置”错误

gwo2fgha  于 2023-04-05  发布在  Docker
关注(0)|答案(1)|浏览(87)

我尝试在Sping Boot 应用程序中使用Vault,并创建了以下docker-compose和vault.json文件。

version: '3.8'

services:
  vault:
    container_name: vault
    image: vault
    restart: always
    environment:
      VAULT_ADDR: http://127.0.0.1:8200
    entrypoint: vault server -config=/vault.json
    ports:
      - '8200:8200'
    volumes:
      - ./volumes/logs:/vault/logs
      - ./volumes/file:/vault/file
      - ./volumes/config:/vault/config
    cap_add:
      - IPC_LOCK
{
    "backend": {
        "file": {
            "path": "/vault/file"
        }
    },
    "listener": {
        "tcp": {
            "address": "0.0.0.0:8200",
            "tls_disable": 1
        }
    },
    "ui": true,
    "disable_mlock": true
}

并将它们保存在同一目录中,然后尝试在此目录中使用bashcmd运行以下命令:

docker-compose up --build

但它给出以下消息和错误:
[+]正在运行1/1 Container vault已重建0.1s正在连接到vault vault|从vault.json加载配置时出错:stat vault.json:没有这样的文件或目录
我在entrypoint: vault server -config=/vault.json线上试了很多组合,但还是同样的问题。如何解决?

vc9ivgsu

vc9ivgsu1#

您需要在volume部分添加vault.json

volumes:
  - ./vault.json:/vault.json

您的合成文件应更改为:

version: '3.8'

services:
  vault:
    container_name: vault
    image: vault
    restart: always
    environment:
      VAULT_ADDR: http://127.0.0.1:8200
    entrypoint: vault server -config=/vault.json
    ports:
      - '8200:8200'
    volumes:
      - ./volumes/logs:/vault/logs
      - ./volumes/file:/vault/file
      - ./volumes/config:/vault/config
      - ./vault.json:/vault.json
    cap_add:
      - IPC_LOCK

相关问题