0

I want to deploy ThingsBoard as a Docker container. I use this image and I try to overwrite some environment variables to get connection with an external Postgres database.

I simply have a Postgres running on localhost:5432 with (empty) database thingsboard, I create the Docker volumes mytb-data and mytb-logs and I launch:

docker run -it -p 9090:9090 -p 1883:1883 -p 5683:5683/udp -v mytb-data:/data -v mytb-logs:/var/log/thingsboard -e SPRING_DATASOURCE_URL=jdbc:postgresql://localhost:5432/thingsboard -e SPRING_DATASOURCE_USERNAME=postgres -e SPRING_DATASOURCE_PASSWORD=<MY_PASSWORD_HERE> --name mytb --restart=always thingsboard/tb-postgres

The container starts, but the logs report the following error:

2020-11-03 07:55:40,480 [main] ERROR o.h.e.jdbc.spi.SqlExceptionHelper - ERROR: relation "admin_settings" does not exist
  Position: 152
... [OMITTED]
Caused by: org.postgresql.util.PSQLException: ERROR: relation "admin_settings" does not exist
  Position: 152
        at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2455)
        at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2155)
        at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:288)
        at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:430)
        at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:356)
        at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:168)
        at org.postgresql.jdbc.PgPreparedStatement.executeQuery(PgPreparedStatement.java:116)
        at com.zaxxer.hikari.pool.ProxyPreparedStatement.executeQuery(ProxyPreparedStatement.java:52)
        at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeQuery(HikariProxyPreparedStatement.java)
        at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:57)
        ... 166 common frames omitted
pg_ctl: could not send stop signal (PID: 9): No such process

Any idea why this happens?

1
  • This looks like the database is not prepared. In manual installation you will run the script /usr/share/thingsboard/bin/install/install.sh to do this. I'm not sure if this is done automatigically by the docker scripts.
    – lupz
    Commented Nov 10, 2020 at 13:45

2 Answers 2

0

The environment variables shall be delimited with quotes '[...]' in Docker launch command.

This is not necessary in Docker Compose.

For Docker, launch

docker run -it -p 9090:9090 -p 1883:1883 -p 5683:5683/udp --name thingsboard --restart always -e SPRING_DATASOURCE_URL='<URL>' -e SPRING_DATASOURCE_USERNAME='<USERNAME>' -e SPRING_DATASOURCE_PASSWORD='<PASSWORD>' thingsboard/tb-postgres

Moreover, I was able to solve the issue using the following configuration (Docker Compose, similar for Docker):

thingsboard:
container_name: thingsboard
image: thingsboard/tb-postgres
restart: always
environment:
    - SPRING_DATASOURCE_URL=jdbc:postgresql://<HOSTNAME>:<PORT>/thingsboard
    - SPRING_DATASOURCE_USERNAME=<USERNAME>
    - SPRING_DATASOURCE_PASSWORD=<PASSWORD>
ports:
    - '9090:9090'
    - '1883:1883'
    - '5683:5683/udp'
0

Inside mytb-data is created the postgres folder call db, or if you have the db postgres folder in another place do the next in that place. I consider you have DB folder in the ...mytb-data/db you have to do the next: chown -R postgres mytbpe-data/db

Because the folder db is created with another user and is the user postgres who is going to use that folder, with this most probably you will fix the problem, I had the same problem and with this I fixed it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.