3

I'm trying to run Rancher as a container using a postgresql database, instead of the Rancher database. In the documentation (http://docs.rancher.com/rancher/installing-rancher/installing-server/) is written that you can use an external database but it mentions only mysql. I was wondering if it is possible to use another external database like postgresql. So, i tried starting the container with the below command pointing it to the postgresql database running on the same host as the container:

docker run -d --restart=always -p 8080:8080 -e CATTLE_DB_CATTLE_MYSQL_HOST=127.0.0.1 -e CATTLE_DB_CATTLE_MYSQL_PORT=5432 -e CATTLE_DB_CATTLE_MYSQL_NAME=db_name -e CATTLE_DB_CATTLE_USERNAME=db_user -e CATTLE_DB_CATTLE_PASSWORD=some_password rancher/server

The above results in the container starting up but without using the postgresql database which i'm telling it to use. It uses instead the Rancher database.

Tried also with the below but still the same results:

docker run -d --restart=always -p 8080:8080 -e CATTLE_DB_CATTLE_HOST=127.0.0.1 -e CATTLE_DB_CATTLE_PORT=5432 -e CATTLE_DB_CATTLE_NAME=db_name -e CATTLE_DB_CATTLE_USERNAME=db_user -e CATTLE_DB_CATTLE_PASSWORD=some_password rancher/server

I'm thinking that either the arguments that i've passed are wrong, or Rancher supports only mysql as an external database.

Any ideas/suggestions ?

Thank you,

Pier
  • 351
  • 2
  • 4
  • 16
  • What kind of networking configuration are you using here? If postgres is running on your host then 127.0.0.1 is not going to point to it unless you are using `--net="host"` (this isn't clear from the Rancher docs). – johnharris85 May 04 '16 at 11:47
  • And don't do that ^^ anyway, use docker networking ;) – johnharris85 May 04 '16 at 11:58
  • @JHarris, 127.0.0.1 was as an example (obviously a wrong one). I actually use the host's name. – Pier May 04 '16 at 13:51
  • What host's name? That won't resolve to anything unless you've done something special or configured some networking that you haven't covered here. Where is postgres running? In another container? On your host? On another host? Are you running this plain Docker? Or using compose? – johnharris85 May 04 '16 at 17:32

1 Answers1

6

MySQL is the only supported database. (and H2, for integration tests)

All the database interaction is through abstractions that are theoretically database-agnostic, but we don't package the driver for or ever test against Postgres. According to this old PR there are a bunch of small issues with things like the the column type names that would have to be addressed. To attempt to use it you would have to set CATTLE_DB_CATTLE_DATABASE=postgres, what you're doing now is trying to connect the MySQL (actually MariaDB) client to a Postgres port and they have no idea how to talk to each other.

  • 1
    Rancher 1.2+ have that PR merged and include experimental support for Postgres through these settings: https://github.com/rancher/cattle/blob/master/resources/content/cattle-global.properties#L48-L68 – Vincent Fiduccia Jan 30 '17 at 22:57
  • 2
    Has there been any development on the experimental support? – Georgi Sep 05 '17 at 12:23