Search code examples
postgresqldockerrundeck

Docker Rundeck + local Postgres


I'm trying to run a docker image of rundeck, using PostGres for the database.

The issue I'm having is mapping my local postgres installation to the docker rundeck image. The postgres port runs on 5432, and have confirmed using netstat that the port is open and listening. The port for rundeck needs to run on 4440.

I have tried the following command:

docker run -p 127.0.0.1:4440:4440 -e RUNDECK_DATABASE_URL=jdbc:postgresql://localhost/rundeck -e RUNDECK_DATABASE_DRIVER=org.postgresql.Driver -e RUNDECK_DATABASE_USERNAME=xxx -e RUNDECK_DATABASE_PASSWORD=xxx --name test-rundeck -t rundeck/rundeck:3.0.19 

But it fails with an error: Connection to 127.0.0.1:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP

I'm guessing it's because the internal 5432 port isnt mapped to the docker container port 5432?

I tried mapping the ports with -p 127.0.0.1:5432:5432 but that fails with the error:

Error starting userland proxy: listen tcp 127.0.0.1:5432: bind: address already in use

At this point I might just resort to running both PostGres and Rundeck as docker images, but I would rather like to resolve this problem.

Any ideas on how to map a local PostGres to a docker ran Rundeck?


Solution

  • Found the answer.

    Had to edit the pg_hba.conf file to allow the docker0 ip address through.

    host    all             all             172.23.0.0/16           md5