Newbie: Can't get apps to run after restart (using rails, postgre, docker and dokku)

October 7, 2014 4.4k views

Hi, I deployed my app to droplet with rails, postgre, docker and dokku.

All was running smoothly, until I restarted the server today and I got into two problems:

1) One rails app said it was already running. The app said, there was /app/tmp/pids/ file but I couldn't find the file in the image though using find / | grep ''

2) Other app couldn't connect to the postgres, which after an inspection shows that is running on a different port. I tried re-deploying, re-establishing the postgre link through dokku and nothing happened, same error.

Eventually, I restarted the app2 with bad postgre through docker, that made things even worse and I have now two apps that won't start.

Also I am trying to figure out why the hell I have unnamed images which seem to contain the Rails app and database, even tried to erased them and start fresh, but the deeper I dig, the more weird problems I get.

For instance removing the image says a different image is not there:

root@michal-do:~# docker rmi 44ce0ececdb4
Error response from daemon: No such id: ed09b33bb766f286542a2e7b7a71333bfff409f7bac78e42cf35302e29982a24
2014/10/07 09:10:40 Error: failed to remove one or more images
root@michal-do:~# docker images
REPOSITORY           TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
<none>               <none>              44ce0ececdb4        24 minutes ago      1.264 GB
dokku/fulcrum        latest              c10d700243b2        4 hours ago         1.242 GB
<none>               <none>              cc27ac49e4a6        4 hours ago         1.264 GB
postgresql/fondio    latest              fdf7f34be819        5 hours ago         310.5 MB
postgresql/fulcrum   latest              dbc9d1eb0ced        7 weeks ago         310.5 MB
<none>               <none>              cca64120d443        7 weeks ago         310.5 MB
kloadut/postgresql   latest              9ed9651b7b98        7 weeks ago         310.5 MB
ubuntu               trusty              c4ff7513909d        8 weeks ago         225.4 MB
progrium/buildstep   latest              cbac8f84e925        11 weeks ago        1.151 GB
ubuntu               14.04               e54ca5efa2e9        3 months ago        276.5 MB

I seem to run into some newbie stuff I can't even google answers for so any help is greatly appreciated.

1 Answer

Dokku can be a great way to deploy apps because it hides a lot of complexities. Though when it breaks down, that same quality can be quite frustrating. Hopefully, I can help point you in the right direction.

The way Dokku itself restarts apps after a change is by issuing:

dokku release myapp
dokku deploy myapp

This blog post deals with problems relinking apps to postgres after a reboot, and suggests creating this script to help:

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

Let us know if that gets you any further.

  • I'm having a similar issue with Django running on a development server. My app isn't running after I did a Power Cycle with a Snapshot.

    Would the above script be applicable to my situation as well? I just want to make sure I won't lose my data in the DB since I am not able to do a dump. I get the following error when I try to dump the DB:

    pg_dump: [archiver (db)] connection to database "db" failed: could not connect to server:
    Connection refused
    Is the server running on host "ip###" and accepting
    TCP/IP connections on port ##?

    The server does not seem to be running on that port, although my App logs show that the development server is running...


  • Thanks asb, that helped!

    For those who were experiencing something similar to myself: Even though the app complained about being there before, doing dokku deploy myapp started it again just fine.

    Then I just re-linked the app using the script and everything ran smoothly from there.

Have another answer? Share your knowledge.