Ory Kratos Config Mounting via Docker Compose

Viewed 635

I am trying to get ory/kratos (0.7.1-alpha.1) to run. I created a config file that I am trying to mount into the kratos container in a docker-compose file.

Starting the compose the kratos image exits immediately claiming config-errors (nil values).

I double-checked my config file and I have the respective values set.

When commenting-out the volume mount command in the compose file, I get exactly the same error, suggesting that ory does not "see" my mounted config.

I did also chmod 777 the config file.

I tried mounting the full /ory/home directory as well as only mounting the config file itself.

This is the docker-compose.yml i am using:

version: '3'
services:
  nbi-kratos-postgres:
    image: postgres
    volumes:
      - /home/whatever/db_data/postgres_data:/var/lib/postgresql
    ports:
      - "5432:5432"
    environment:
      POSTGRES_USER: my_user
      POSTGRES_PASSWORD: my_pw
      POSTGRES_DB: my_db
    
  nbi-kratos:
    image: oryd/kratos:v0.7.1-alpha.1
    volumes:
#      - /home/whatever/project/kratos:/home/ory
      - /home/whatever/project/kratos/.kratos.yaml:/home/ory/.kratos.yaml
    environment:
      - HOME:/home/ory/

And this is the output when i run docker-compose up:

nbi-kratos_1           |
nbi-kratos_1           | The configuration contains values or keys which are invalid:
nbi-kratos_1           | The configuration contains values or keys which are invalid:
nbi-kratos_1           | identity: <nil>
nbi-kratos_1           |           ^-- one or more required properties are missing
nbi-kratos_1           |
nbi-kratos_1           | The configuration contains values or keys which are invalid:
nbi-kratos_1           | selfservice.default_browser_return_url: <nil>
nbi-kratos_1           |                                         ^-- one or more required properties are missing
nbi-kratos_1           |
nbi-kratos_1           | The configuration contains values or keys which are invalid:
nbi-kratos_1           | courier.smtp.connection_uri: <nil>
nbi-kratos_1           |                              ^-- one or more required properties are missing
nbi-kratos_1           |
nbi-kratos_1           | time=2021-07-27T13:52:32Z level=fatal msg=Unable to instantiate configuration. audience=application error=map[message:I[#] S[#] validation failed
nbi-kratos_1           |   I[#] S[#/required] missing properties: "identity", "dsn"
nbi-kratos_1           |   I[#/selfservice] S[#/properties/selfservice/required] missing properties: "default_browser_return_url"
nbi-kratos_1           |   I[#/courier/smtp] S[#/properties/courier/properties/smtp/required] missing properties: "connection_uri"] service_name=Ory Kratos service_version=v0.7.1-alpha.1
nbience_nbi-kratos_1 exited with code 1
1 Answers

You need to pass the config to kratos with the command:

command: -c home/ory/.kratos.yaml serve

Your kratos service might be like there

nbi-kratos:
  image: oryd/kratos:v0.7.1-alpha.1
  volumes:
    - .home/whatever/project/kratos:/home/ory
  command: -c home/ory/.kratos.yaml serve
Related