First dokku deploy

October 26, 2016 544 views
Dokku PostgreSQL Debian

I have an express app (based on kyt-starter-universal) with postgresql database and I struggle to figure it out.
Setting up Debian 8.6 and installing dokku was easy. After that:

sudo dokku plugin:install postgres
dokku apps:create myapp
dokku postgres:create myapp-db
dokku postgres:link myapp-db myapp

And then I'm kinda lost. I need to dump sql data to my app container, so executed locally:

pg_dump -U postgres -Fc localapp-db > database.dump

Do I need to grant any privileges in advance to be able access it, like:


Next step: uploading it to my cloud and executed:

dokku postgres:import myapp-db < database.dump

Here things got ugly - it showed me bunch of errors and failed (hence my question about privileges). Tried it second time - no errors. I tried to check my db, but my knowledge only works to this point.
Tried dokku postgres:expose myapp-db but I was unable to figure out how to connect from my local pgAdmin3 installation.

I'm not sure how to set my local app config. From this tutorial: I assume I need to use process.env.DATABASE_URL?

Actual deploying is also a mystery to me. For example using public folder: AFAIK after pushing my git project do dokku container it will execute npm start to build and start my app. But I am supposed to have user uploaded files there, how to ensure they won't be lost on next deploy? Can I browse its content from the container?

Bonus: I still don't have a domain name, when I'm setting dokku/nginx can I use the hostname I am supposed to have later (, or I have to configure it later?

Sorry, this question is too long, but I am kinda frustrated after few days of failures.

1 Answer
  • If you want to connect to a postgres instance externally, you'll need to use the postgres:expose command as you did. You can then connect to the ip of the server and the credentials provided by the postgres:info command. Note that the exposed ip will also be available in that command.
  • Yep, thats probably the url you want to connect, as we'll set a DATABASE_URL env var for your application.
  • You can use the official persistent-storage plugin to store uploaded files. I would be sure that the uploaded files directory only contains uploaded files, and that you don't mix it with assets in your application.
  • You can configure a domain name after the fact using the official domains plugin.

I would definitely read through our docs, I'd say we cover many common use cases and (hopefully) the docs are well structured and easy to read. If you think you can clarify something, jut click the pencil icon on the sidebar of our documentation, or if you're unclear, I recommend:

Good luck!

  • Dokku Maintainer
Have another answer? Share your knowledge.