Cannot start database postgres - Docker-compose

Hey guys, I’m trying to start a simple docker-compose with a sdk server, nlu server and a postgres server.

My docker-compose.yml:

version: '3'
services:
  rasa_nlu:
    restart: always
    image: acqua:v1
    depends_on:
    - postgresql
    expose:
    - 5005
    ports:
    - "5005:5005"
    volumes:
    - "/home/initiate/codigos/acqua_madre/jo_minimum:/rasa"
    - /home/initiate/codigos/acqua_madre/database:/var/lib/postgresql/data
    command: "rasa run --enable-api --cors '*' --endpoints endpoints.yml"
  rasa_actions:
    depends_on:
    - rasa_nlu
    restart: always
    image: acqua:v1
    expose:
    - 5055
    volumes:
    - "/home/initiate/codigos/acqua_madre/jo_minimum:/rasa"
    command: "rasa run actions"
  postgresql:
    image: postgres:latest
    restart: always
    environment:
      POSTGRES_PASSWORD: "rasa"
      POSTGRES_USER: "rasa"
      PostGRES_DB: "/var/lib/postgresql/data/rasa.db"
    volumes:
      #- "/home/initiate/codigos/acqua_madre/jo_minimum/rasa.db:/var/lib/postgresql/rasa.db"
      - /home/initiate/codigos/acqua_madre/database:/var/lib/postgresql/data
    expose:
    - 5432

My endpoints.yml:

action_endpoint:
  url: "http://rasa_actions:5055/webhook"

# Tracker store which is used to store the conversations.
# By default the conversations are stored in memory.
# https://rasa.com/docs/rasa/tracker-stores
tracker_store:
    type: SQL
    dialect: "postgresql"  # the dialect used to interact with the db
    url: "postgresql"  # (optional) host of the sql db, e.g. "localhost"
    port: "5432"
    login_db: "rasa"
    db: "/var/lib/postgresql/rasa.db"  # path to your db
    username: rasa # username used for authentication
    password: rasa # password used for authentication
    query: # optional dictionary to be added as a query string to the connection URL

This is the log from postgres:

The files belonging to this database system will be owned by user "postgres".,
This user must also own the server process.,
,
The database cluster will be initialized with locale "en_US.utf8".,
The default database encoding has accordingly been set to "UTF8".,
The default text search configuration will be set to "english".,
,
Data page checksums are disabled.,
,
fixing permissions on existing directory /var/lib/postgresql/data ... ok,
creating subdirectories ... ok,
selecting dynamic shared memory implementation ... posix,
selecting default max_connections ... 100,
selecting default shared_buffers ... 128MB,
selecting default time zone ... Etc/UTC,
creating configuration files ... ok,
running bootstrap script ... ok,
performing post-bootstrap initialization ... ok,
initdb: warning: enabling "trust" authentication for local connections,
You can change this by editing pg_hba.conf or using the option -A, or,
--auth-local and --auth-host, the next time you run initdb.,
syncing data to disk ... ok,
,
,
Success. You can now start the database server using:,
,
    pg_ctl -D /var/lib/postgresql/data -l logfile start,
,
waiting for server to start....2021-11-25 16:51:16.070 UTC [50] LOG:  starting PostgreSQL 14.1 (Debian 14.1-1.pgdg110+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit,
2021-11-25 16:51:16.075 UTC [50] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432",
2021-11-25 16:51:16.097 UTC [51] LOG:  database system was shut down at 2021-11-25 16:51:15 UTC,
2021-11-25 16:51:16.110 UTC [50] LOG:  database system is ready to accept connections,
 done,
server started,
CREATE DATABASE,
,
,
/usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/*,
,
2021-11-25 16:51:16.591 UTC [50] LOG:  received fast shutdown request,
2021-11-25 16:51:16.594 UTC [50] LOG:  aborting any active transactions,
2021-11-25 16:51:16.598 UTC [50] LOG:  background worker "logical replication launcher" (PID 57) exited with exit code 1,
waiting for server to shut down....2021-11-25 16:51:16.608 UTC [52] LOG:  shutting down,
2021-11-25 16:51:16.644 UTC [50] LOG:  database system is shut down,
 done,
server stopped,
,
PostgreSQL init process complete; ready for start up.,
,
2021-11-25 16:51:16.762 UTC [1] LOG:  starting PostgreSQL 14.1 (Debian 14.1-1.pgdg110+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit,
2021-11-25 16:51:16.762 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432,
2021-11-25 16:51:16.763 UTC [1] LOG:  listening on IPv6 address "::", port 5432,
2021-11-25 16:51:16.771 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432",
2021-11-25 16:51:16.782 UTC [64] LOG:  database system was shut down at 2021-11-25 16:51:16 UTC,
2021-11-25 16:51:16.802 UTC [1] LOG:  database system is ready to accept connections,
2021-11-25 16:52:08.033 UTC [71] ERROR:  syntax error at or near "/" at character 17,
2021-11-25 16:52:08.033 UTC [71] STATEMENT:  CREATE DATABASE /var/lib/postgresql/data/rasa,
2021-11-25 16:52:08.053 UTC [72] FATAL:  database "/var/lib/postgresql/data/rasa" does not exist,
2021-11-25 16:52:49.721 UTC [74] FATAL:  database "/var/lib/postgresql/data/rasa" does not exist,
2021-11-25 16:52:49.740 UTC [75] FATAL:  database "/var/lib/postgresql/data/rasa" does not exist,
2021-11-25 16:52:51.333 UTC [76] FATAL:  database "/var/lib/postgresql/data/rasa" does not exist

Does anyone has any idea of how I can solve this? Thanks in advance! :smiley:

@initiate Is you able to login to Postgres after Image is running on docker?

1 Like

I actually don’t know, how can I know?

@initiate I guess you using docker-compose --build command if so, this command pull the images you have mentioned and when everything run without an error. Just type docker ps -a it will show you running ports and status

@initiate I can see your posgre image is incomplete as you not mentioned dpage/pgadmin4

@initiate did you installed docker desktop? It will help you a lot to see the actions logs.

1 Like

Sorry, I’m new to all this. Is this other image that I need to run in the stack? If so I think I’m going to try to implement the MySQL as seen in this response:

What do you think?

I’m using portainer for that.

@initiate Did you tried working locally first (without using docker), while installing rasa, rasa x and Postgres ?

1 Like

I’m trying not to use rasa x. Trying to understand rasa “vanilla”. Is it possible?

@initiate no issue, you can simply use rasa open source. Can I ask why you want to use Postgres? I’m what is your use case?

1 Like

I’m just trying to create a demo, something minimal. I actually prefer that the database is a file. I think I took the wrong path choosing Postgres. :confused:

How can I create a simple db with the user/bot history in a rasa.db file?

@initiate If you want to store the bot/user conversation in Postgres follow these steps:

Step1: You should have a bot ready in rasa

Step2: Install PosgresDB in your machine with the credentials.

Step3: Follow this thread: How to configure rasa.db file in a different location? - #3 by nik202

Step4. Run the rasa using rasa run -m models --enable-api --cors "*" --debug | this will run on port 5005

Step5. If you are using custom action server just run active server in new terminal i.e rasa run actions | This will run on port 5055

Step6: Open the PostgresDB with credentials and you will see the bot user conversation store in db

Follow and let me know, if you faced any issue. Good Luck!

1 Like