Error (failed_to_start_child) when running ecto in ejabberd production mode inside docker

I added ecto to ejabberd, which worked fine in dev mode (run with iex -S mix), but when ejabberd is compiled and started I get this error:

07:02:09.214 [error] Failed to start module <module-name>: 

I’m starting Ejabberd.Repo from custom ejabberd module:

def init(:ok) do
    children = [
    worker(Ejabberd.Repo, [])

   Supervisor.init(children, strategy: :one_for_one)

def start(host, _opts) do
  info("Starting ejabberd module #{__MODULE__} at #{host}")
  :gen_iq_handler.add_iq_handler(:ejabberd_local, host, @namespace, __MODULE__, :on_iq_received)
  Supervisor.start_link(__MODULE__, :ok, [])

Ejabberd.Repo is defined in lib/ejabberd/repo.ex:

defmodule Ejabberd.Repo do 
  use Ecto.Repo,           
    otp_app: :ejabberd,
    adapter: Ecto.Adapters.Postgres 

connection setup inisde config/config.exs:

config :ejabberd, ecto_repos: [Ejabberd.Repo]

config :ejabberd, Ejabberd.Repo,
  adapter: Ecto.Adapters.Postgres,
  database: "<database-name>",
  username: "<username>",    
  password: "<password>",      
  hostname: "<host>"

application setup from mix.exs:

def application do       
  [mod: {:ejabberd_app, []},
   applications: [:kernel, :stdlib, :sasl, :ssl],
   included_applications: [:lager, :mnesia, :inets, :p1_utils, :cache_tab,
                           :fast_tls, :stringprep, :fast_xml, :xmpp, :mqtree,
                           :stun, :fast_yaml, :esip, :jiffy, :p1_oauth2,
                           :eimp, :base64url, :jose, :pkix, :os_mon, :ecto, :postgrex, :telemetry]
   ++ cond_apps()]       

deps from mix.exs:

defp deps do
    {:lager, "~> 3.6.0"},
    {:p1_utils, "~> 1.0"},
    {:fast_xml, "~> 1.1"},
    {:xmpp, "~> 1.3.0"},
    {:cache_tab, "~> 1.0"},
    {:stringprep, "~> 1.0"},
    {:fast_yaml, "~> 1.0"},
    {:fast_tls, "~> 1.1"},
    {:stun, "~> 1.0"},
    {:esip, "~> 1.0"},
    {:p1_mysql, "~> 1.0"},
    {:mqtree, "~> 1.0"},
    {:p1_pgsql, "~> 1.1"},
    {:jiffy, "~> 0.14.7"},
    {:p1_oauth2, "~> 0.6.1"},
    {:distillery, "~> 2.0"},
    {:pkix, "~> 1.0"},
    {:ex_doc, ">= 0.0.0", only: :dev},
    {:eimp, "~> 1.0"},
    {:base64url, "~> 0.0.1"},
    {:jose, "~> 1.8"},
    {:ecto_sql, "~> 3.0"},
    {:postgrex, ">= 0.0.0"}
  ++ cond_deps()

link to official docker repo (, only change to docker file is that it is copying files from local version instead cloning it

I guess ejabberd cannot find configuration for ecto, but I don’t know where to put it. I’ve tried adding setup to rel/prod.exs, but it doesn’t make a difference.

Am I missing something? How can I make more sense of this error?

Source: StackOverflow