Closed dankimio closed 10 years ago
Same issue here. Fired up a dokku instance last night with Postgres for a Flask app I'm developing. Port changes on restart.
I think a potential fix is to ensure that the plugin interrogates docker for the port rather than stashing it for re-use. I'll try and get something together for a PR as this is messing me up too.
+1
Same issue with the mariadb plugin
Right. I've re-factored the plugin to dynamically get the port/id of the application name you are after. My fork is here: https://github.com/scourou/dokku-pg-plugin
I'd appreciated if people could test it out, as I only started using dokku this morning, and I can't be certain I've not screwed something up. If all is well, I'll format into a proper PR to get it merged back in. Short on time at the moment.
I removed the current plugin:
$ cd /var/lib/dokku/plugins
$ rm -rf postgresql
$ docker rmi <postgresql image ID>
Then installed your fork. I get the following error when I try to link a DB:
$ dokku postgresql:create mydb
$ dokku postgresql:link myapp.com mydb
> cat: /home/dokku/.postgresql/port_mydb: No such file or directory
EDIT: Dokku 0.2.3 on Ubuntu 14.04
Should line 184 be
PORT=$(get_postgresql_port)
Instead of
PORT=$(cat "$DOKKU_ROOT/.postgresql/port_$3")
That'll teach me to not rush fixes. :) Will fix and update asap.
Updated my fork, and have issued PR.
Thanks !
Thank you!
An alternative fix for this is to modify the docker run command to specify both container port and host port. I changed this line to the following. This way, my container port never changes and I don't have to do anything after rebooting. ID=$(docker run -v $VOLUME -p 5432:5432 -d $DB_IMAGE /usr/bin/start_pgsql.sh $DB_PASSWORD)
I've created a Postgres database and linked it with a Rails app. Everything worked fine until I restarted the server. After restart Docker Postgres container received a new port and Rails application wasn't able to connect to it. If I run dokku
postgresql:info myapp
it shows the old port, but it has changed (relinking also gives the old port). It only works if I hardcode the port inconfig.yml
file. It also works when I manually changeDATABASE_URL
variable throughdokku config:set
command.