-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
private ip address changes upon restart, apps try to use old ip #6
Comments
Name and link is the 'best' solution here. However I don't think dokku supports starting the app containers with the link flags. I'll try to ping the dokku devs and see if they have any suggestions. |
Ok, I think i have a solution here. Can you test out this branch: https://github.com/jeffutter/dokku-postgresql-plugin/tree/docker-name-link You will need either delete and re-create your DB or change some things in your $DOKKU_ROOT/$APP/ENV They need to be changed to look like this: https://github.com/jeffutter/dokku-postgresql-plugin/blob/docker-name-link/commands#L60-L63 Note that the it uses seperate variables for the user, password and db_name. And then sets DATABASE_URL to literally equal '"postgress://${DATABASE_APP}:${DATABASE_PASS}@${DATABASE_PORT_5432_TCP_ADDR}:${DATABASE_PORT_5432_TCP_PORT}/${DATABASE_DB}"' This causes that ENV variable to be set from the other variables when the container is launched and thus can pull the ip/port from the -link command. It's kinda hacky but it works. |
This is not quite working for me; the DATABASE_URL env var in my app doesn't get the host or port.
|
This is odd. DATABASE_PORT_5432_TCP_PORT should be set in the ENV of the container by docker. It seems like none of the ENV vars are being set. Are you using a current build of dokku? Perhaps something changed recently. Can you check your docker ps output that the postgresql container has the name of the app listed under Names. It should look something like dokku-postgresql, appname/database |
Dokku v0.2.1, which has been current for a while now. Docker ps shows
|
Can you check on a couple more things for me. 1.) Does $DOKKU_ROOT/.postgresql/pass_$APP_NAME exist? It should be a file containing the password for the database user for the app |
I think the reason this isn't working is that Dokku v0.2.1 doesn't implement |
@poirier Good observation. This is the issue. I thought docker-args had been implemented for a while but I guess it wasn't in v0.2.1 Would you care to try with a more recent version? |
I haven't had time to get things working completely again with the master branch of dokku, but I have gotten far enough to see a complete DATABASE_URL in my app and verify the app can access the database. |
OK, thanks for troubleshooting and reminding me docker-args isn't in a dokku release. I'll ping the dokku guys to see if they will release soon. Until then this will have to remain a separate branch. |
any plans to merge docker-name-link back into master? |
+1 Im running into this hassle as well. This seems like a common scenario. The setup should be able to survive a server reboot. |
I found a solution. I'm using the virtual network gateway IP address rather than the container's To make the postgres auto start on reboot, I added this to my /etc/rc.local: # make sure the output is logged somewhere
exec 2> /tmp/rc.local.log # send stderr from rc.local to a log file
exec 1>&2 # send stdout to the same log file
set -x # tell sh to display commands before execution
echo "Starting postgres container"
/usr/local/bin/dokku postgresql:start |
Latest thoughts on this? Biggest pain with this plugin :( |
when initially setting up a database for an app the current private ip for the postgres container is written to the ENV file, then if the container is stopped and a new one created it (usually?) has a different private ip.
what i currently do is hand modify each ENV file to point to the new address, then dokku release $APP && dokku deploy $APP. i'd like to automate this so that it automagically finds all apps (potentially looking at /home/dokku/.postgresql/pass_*), tweaks their ENV, and re-deploys if currently running.
another probably better idea is to implement the new-ish (docker >= 0.6.5) '-name postgresql' combined with 'link' on the app run, although i need to look into that a bit more to make sure it does what i think.
the reason i haven't done this yet is that i'm curious how other people handle this, or if it is taken care of somehow that i just don't have set up or am missing.
The text was updated successfully, but these errors were encountered: