Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing information/config for postgres from docker linux installation guide #428

Open
1 of 2 tasks
pomali opened this issue Oct 12, 2020 · 12 comments
Open
1 of 2 tasks

Comments

@pomali
Copy link

pomali commented Oct 12, 2020

This is a...

  • Feature Request
  • Bug Report

Problem:
Documentation for Docker for Linux/Mac is missing information about postgres
https://thingsboard.io/docs/user-guide/install/docker/?ubuntuThingsboardQueue=inmemory

When you are installing based on this documentation you have no idea that there should be postgres installed somewhere, it is missing from "Prerequisites" and there is no mention about it in text. So you end up with org.postgresql.util.PSQLException: FATAL: database "thingsboard" does not exist error.

Proposed Solution:

Based on issue thingsboard/thingsboard#3347 there is example docker-compose.yml that has postgres included which fixes problem with missing postgres.

docker-compose.yml

version: '2.2'
services:
  mytbpe:
    restart: always
    image: "thingsboard/tb-postgres"
    ports:
      - "8080:9090"
      - "1883:1883"
      - "5683:5683/udp"
    environment:
      TB_QUEUE_TYPE: in-memory
      SPRING_DATASOURCE_USERNAME: postgres
      SPRING_DATASOURCE_PASSWORD: postgres
      SPRING_DATASOURCE_URL: jdbc:postgresql://postgres:5432/thingsboard
    volumes:
      - ~/.mytb-data:/data
      - ~/.mytb-logs:/var/log/thingsboard
  postgres:
    restart: always
    image: "postgres:11.6"
    ports:
    - "5432"
    environment:
      POSTGRES_DB: thingsboard
      POSTGRES_PASSWORD: postgres
    volumes:
      - ~/.mytb-data/db:/var/lib/postgresql/data

Page to Update:
https://thingsboard.io/docs/user-guide/install/docker/?ubuntuThingsboardQueue=inmemory

I don't mid creating PR but wasn't sure that this is preferred solution

@PL4typus
Copy link

Can confirm that following instructions doesn't lead to success.

Also, using the thingsboard/tb image with embedded HSQLDB database doesn't work with the docker command provided.

@PL4typus
Copy link

@pomali I tried the provided docker-compose.yml file and get the following error:

Starting thingsboard_postgres_1 ... done
Recreating thingsboard_mytbpe_1 ... done
Attaching to thingsboard_postgres_1, thingsboard_mytbpe_1
postgres_1  | 
postgres_1  | PostgreSQL Database directory appears to contain a database; Skipping initialization
postgres_1  | 
postgres_1  | 2020-12-16 16:00:54.943 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
postgres_1  | 2020-12-16 16:00:54.943 UTC [1] LOG:  listening on IPv6 address "::", port 5432
postgres_1  | 2020-12-16 16:00:54.959 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
postgres_1  | 2020-12-16 16:00:55.001 UTC [26] LOG:  database system was shut down at 2020-12-16 15:58:10 UTC
postgres_1  | 2020-12-16 16:00:55.008 UTC [1] LOG:  database system is ready to accept connections
mytbpe_1    | psql: could not connect to server: No such file or directory
mytbpe_1    | 	Is the server running locally and accepting
mytbpe_1    | 	connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

How can this be fixed ? Thanks for your time.

@pomali
Copy link
Author

pomali commented Dec 16, 2020

This looks like if mytbpe_1 isn't reading environment variables and is trying to connect using sockets instead of network.
But I don't remember, if I had some similar problem. I would check if YAML has correct indentation and if mytbpe_1 is getting environment set.

@PL4typus
Copy link

It does read environment variables, apparently:

$ docker-compose run mytbpe /bin/bash
Starting thingsboard_postgres_1 ... done
thingsboard@cf53e2d73fc3:/$ echo $SPRING_DATASOURCE_URL
jdbc:postgresql://postgres:5432/thingsboard

I tried touching up the docker-compose.yml file, with no success so far:

version: "3.4"                                                                                                                                                               
services:
    mytbpe:
        restart: always
        image: "thingsboard/tb-postgres"
        depends_on:
            - postgres
        ports:
            - "8080:9090"
            - "1883:1883"
            - "5683:5683/udp"
        environment:
            - TB_QUEUE_TYPE=in-memory
            - SPRING_DATASOURCE_USERNAME=postgres
            - SPRING_DATASOURCE_PASSWOR= postgres
            - SPRING_DATASOURCE_URL=jdbc:postgresql://postgres:5432/thingsboard
        volumes:
            - ~/.mytb-data:/data
            - ~/.mytb-logs:/var/log/thingsboard

    postgres:
        restart: always
        image: "postgres:11.6"
        ports:
            - "5432"
        environment:
            - POSTGRES_DB=thingsboard
            - POSTGRES_USER=postgres
            - POSTGRES_PASSWORD=postgres
        volumes:
            - ~/.mytb-data/db:/var/lib/postgresql/data

I added a depends_on to make sure that the database container starts first.

@PL4typus
Copy link

Also, adding more specifically to this issue: there are instructions here that are completely different from what's currently in documentation. Or maybe I missed something?

@wodz
Copy link

wodz commented Dec 21, 2020

I had it working once with docker-compolse.yml as above. Then I wanted to upgrade to 3.2 and it failed. Removing volumes and recreating doesn't solve the problem as well. I also get
thingsboard_1 | psql: could not connect to server: No such file or directory
thingsboard_1 | Is the server running locally and accepting
thingsboard_1 | connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
Docs are still not updated https://thingsboard.io/docs/user-guide/install/docker/

@woland7
Copy link

woland7 commented Feb 17, 2021

Still not updated.

@dreaquil
Copy link

dreaquil commented May 23, 2021

Still not updated. Can we get some clarity on what is the correct way to install using Docker?

@dreaquil
Copy link

dreaquil commented Jun 3, 2021 via email

@trypzz
Copy link
Contributor

trypzz commented Jun 4, 2021

Hi Bogdan, It seems you have removed your reply from this issue. Can you update on the plan for this please? Kind regards, André

On Thu, Jun 3, 2021 at 10:24 AM Bogdan @.***> wrote: Hello everyone. I'm confirm this case. Working on fix. — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#428 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHXU6I2RT65VWV6TCEINLBLTQ5C3XANCNFSM4SMYIFXQ .
-- Regards, André

Hello, yes.

I'm confirm problems with docker image. Postgres cant initialize the database inside of container. Waiting for news from our developers.

@dreaquil
Copy link

dreaquil commented Jun 9, 2021

Hi @trypzz,

Is there any progress on this? or any intermediate suggestion please?

@trypzz
Copy link
Contributor

trypzz commented Jun 10, 2021

Hi @trypzz,

Is there any progress on this? or any intermediate suggestion please?

Temporary you can change permission on docker.sock by this command sudo chmod 666 /var/run/docker.sock and try to start docker-compose, but this is not right and you can get some security problems. I did not recommend to use this at production, but this works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants