Comments (14)
The problem is the host IP has changed from 172.17.0.23 to 172.17.0.14.
It seems to me that either the DATABASE_URL variable needs to be automatically updated in this situation, or else the IP needs to be persistent.
from dokku-pg-plugin.
@bluekirby Agree, but i dont think thats something i can configure, right?
from dokku-pg-plugin.
@jvanbaarsen It doesn't seem to be. At a glance it looks like the DATABASE_URL is only updated when a password for the database doesn't already exist (see https://github.com/Kloadut/dokku-pg-plugin/blob/master/commands). Even then, you'd still need to run the create command when the server reboots.
@Kloadut I think the most simple way to fix this is to update the DATABASE_URL environment variable every time the link command is run, but please correct me if I've missed something.
from dokku-pg-plugin.
@bluekirby Can you point me in the direction for the code change? That way i can test it later today on an fork. If it works, i can submit PR
from dokku-pg-plugin.
Related to: dokku/dokku#369
from dokku-pg-plugin.
@jvanbaarsen In https://github.com/Kloadut/dokku-pg-plugin/blob/master/commands, see how the following is nested:
URL="DATABASE_URL=postgres://root:$DB_PASSWORD@$IP/db"
cat "$DOKKU_ROOT/$APP/ENV" | grep "$URL" || echo "export $URL" >> "$DOKKU_ROOT/$APP/ENV"
Changing this won't change the fact that the IP and port provided by docker isn't guaranteed, but it may help prevent a bit of panic when recreating the DB container still appears to fail.
from dokku-pg-plugin.
@bluekirby Are you also using this plugin? If so, how are you dealing with the fact that you cant reboot the server?
If the IP and port is not guaranteed by docker, how can this ever become a stable plugin?
from dokku-pg-plugin.
Yeah, I'm using this plugin at the moment. You can reboot the server, you just have to recreate the postgresql container and update the DATABASE_URL variable manually after you do so (assuming your application is set up to use it, which is recommended).
For me, this translates to:
sudo reboot
dokku postgresql:create database
...
Host: 172.17.0.14
...
dokku config:set app DATABASE_URL=postgres://root:[email protected]/db
Not ideal, but it's working okay for now.
from dokku-pg-plugin.
@bluekirby But when i re-create i wont lose all the data?
from dokku-pg-plugin.
@jvanbaarsen No, the data is persistent. The container doesn't disappear when the server restarts, you just lose your reference to it.
from dokku-pg-plugin.
@bluekirby Ah ok, that will do as a work around (everything is better than using capistrano -_-) Can you also tell me where the PG database is stored? (for backup reasons?)
from dokku-pg-plugin.
You should be able to find it under /var/lib/docker/volumes/
It gets stored under the folder postgresql-appname
. Everything will be inside.
(You'll need to be the root user or otherwise have permissions to access this though)
from dokku-pg-plugin.
@bluekirby I've created a hook that will re-map the IP address in the app, but i'm not sure if this should be a hook (since if its gonna be a hook, the dokku team has to accept my PR first: dokku/dokku#397)
Another option is, i create an extra function you can call via this plugin, something like dokku postgresql:relink APPNAME
What do you think?
This is the hook:
#!/bin/bash
APP="$1";
CURRENT_URL=`dokku config:get $APP DATABASE_URL`
dokku postgresql:create $APP
ID=$(docker ps -a | grep "postgresql/$APP":latest | awk '{print $1}')
IP=$(docker inspect $ID | grep IPAddress | awk '{ print $2 }' | tr -d ',"')
NEW_URL=$(echo $CURRENT_URL | sed -e "s/@.*\//@$IP\//g")
dokku config:set $APP DATABASE_URL=$NEW_URL
from dokku-pg-plugin.
I just fixed the problem by using port instead of local IP, which prevent docker to renew IP at reboot or restart.
Please update the plugin, rebuild the kloadut/postgresql container and the pgsql containers and try again :)
from dokku-pg-plugin.
Related Issues (20)
- Invalid port number in postgresql:link if app and db names is different. HOT 1
- Unable to install HOT 2
- Assumption that docker0 has IP 172.17.42.1
- Cannot start container : port has already been allocated HOT 1
- Rails unable to access through credential... HOT 1
- Rails database.yml file not parsing correctly HOT 7
- Multiple Databases, crossover? HOT 1
- dump command available when postgresql-client not installed HOT 1
- dokku-pg-plugin does not use DOKKU_NOT_IMPLEMENTED_EXIT, leads to misbehaviour with unknown commands
- Unicode
- Multiple Apps, same database HOT 1
- Host and Port information are missing HOT 4
- seems not working with docker 1.7 HOT 15
- DB automatic unlink HOT 1
- postgresql:dump could not change directory to "/root"
- How can I upgrade to postgres 9.4? HOT 5
- Connection timed out HOT 1
- 'psql' not found when executing dokku postgresql:console <db> HOT 2
- "Your docker version is too old, please update it" HOT 5
- Branch josegonzalez/dokku-pg-plugin out of date
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dokku-pg-plugin.