Postgresql Docker

I created a bot that asks user information and stores in postgresql database.it works well in locally. Now I want to deploy it in docker so I need help what are the changes I have to made. can anyone help me. Thanks in advance.

@nik202

@Shan Firstly, check how to create the docker image for postgres and then you need to check the IP address of Docker and ports to be used I guess 5432 is the default port number for Postgres, but container IP is different and localhost is different, you need to inspect the docker container. I hope this will help you. It is very complex process, see some videos.

Thank you @nik202 . can you check this code is correct or not?

FROM rasa/rasa-sdk:2.8.0
WORKDIR /app
USER root
COPY ./actions /app/actions USER 1001

version: “3.0”
services:
rasa:
container_name: rasa-server
image: rasa/rasa:2.8.0-full
ports:
- 5005:5005
volumes:
- ./:/app
command:
- run
- --cors
- “*”
- --enable-api
- --log-file
- out.log
depends_on:
- action-server
action-server:
container_name: action-server1
image: rasa/rasa-sdk:2.8.0
volumes:
- ./actions:/app/actions
ports:
- 5055:5055

changed url into action_endpoint:
url: “http://action-server1:5055/webhook

@Shan Yes, Seems fine hope this one is running?

yes it is running.

@Shan Then? Did you seen what I suggest in my last post?

Yes, I have been trying to do that but it is very complex to understand.

@Shan You need to see and figure it out. Because there is not a tutorial I can share.

Now I want to run the flask in the docker

@Shan Honestly, can I say one thing. One topic one discuss, its Postgres docker not flask.

@Shan Hello, Hope you doing fine? Can I request to please close this pending thread and mark a solution for others. Thanks.

Solution: Docker-Network is used.

@Shan If you later got some time can you elaborate your solution, this will really help other, many thanks in advance and good luck!

Yeah Sure @nik202

Hi @nik202 I have updated my solution.

version: "3.0"
services:
    rasa:
      container_name: rasa
      image: rasa/rasa:2.8.1-full
      ports:
        - 5005:5005
      volumes:
        - ./:/app
      command:
        -  run
        -  -m
        -  models
        -  --enable-api
        -  --cors
        -  "*"
      depends_on:
        - action-server1
        - db
    action-server1:
      container_name: "action-server1"
      build:
        context: actions
      volumes:
        - ./actions:/app/actions
      ports:
        - "5055:5055"
      networks:
        - rasa_network
        - deafult
    db:  # add host='db' in postgres connection
      image: "postgres"
      environment:
        POSTGRESQL_USERNAME: "postgres"
        POSTGRESQL_PASSWORD: "password"
        POSTGRESQL_DATABASE: "postgres"
        POSTGRES_HOST_AUTH_METHOD: "trust"
      volumes:
        - db-data:/var/lib/postgresql/data
      ports:
        - "5432:5432"
      networks:
        - default
volumes:
  db-data
1 Like

@Shan On quick question for you? For Postgres Db the IP address will always change, how you managing that? For example, when you open Postgres in browser with user name and password and at the time of asking localhost ip what you doing in that case, as container generate different IP when we run docker.