Giter Club home page Giter Club logo

dokku-pg-plugin's Introduction

PostgreSQL plugin for Dokku

Project: https://github.com/progrium/dokku

Warning: This plugin is under development and still only tested with the below dependencies

Requirements

  • Docker version 0.7.2 or higher
  • Dokku version 0.2.1 or higher

Installation

cd /var/lib/dokku/plugins
git clone https://github.com/Kloadut/dokku-pg-plugin postgresql
dokku plugins-install

Commands

$ dokku help
    postgresql:console <db>                        Open a PostgreSQL console
    postgresql:create <db>                         Create a PostgreSQL container
    postgresql:delete <db>                         Delete specified PostgreSQL container
    postgresql:dump <db> > dump_file.sql           Dump database data
    postgresql:info <db>                           Display database informations
    postgresql:link <app> <db>                     Link an app to a PostgreSQL database
    postgresql:list                                Display list of PostgreSQL containers
    postgresql:logs <db>                           Display last logs from PostgreSQL container
    postgresql:restore <db> < dump_file.sql        Restore database data from a previous dump

Simple usage

Create a new DB:

$ dokku postgresql:create foo            # Server side
$ ssh dokku@server postgresql:create foo # Client side

-----> PostgreSQL container created: postgresql/foo

       Host: 172.17.42.1
       User: 'root'
       Password: 'RDSBYlUrOYMtndKb'
       Database: 'db'
       Public port: 49187

Deploy your app with the same name (client side):

$ git remote add dokku git@server:foo
$ git push dokku master

Link your app to the database

dokku postgresql:link app_name database_name

Advanced usage

Inititalize the database with SQL statements:

cat init.sql | dokku postgresql:create foo

Open a PostgreSQL console for specified database:

dokku postgresql:console foo

Deleting databases:

dokku postgresql:delete foo

Linking an app to a specific database:

dokku postgresql:link foo bar

PostgreSQL logs (per database):

dokku postgresql:logs foo

Database information:

dokku postgresql:info foo

List of containers:

dokku postgresql:list

Dump a database:

dokku postgresql:dump foo > foo.sql

Restore a database:

dokku postgresql:restore foo < foo.sql

In case Dokku says pg_dump not found when dumping or restoring database:

sudo apt-get install postgresql-client-9.3

dokku-pg-plugin's People

Contributors

banyan avatar belug23 avatar bogdal avatar chrisbranson avatar dschwertfeger avatar elia avatar glebm avatar jaysh avatar kloadut avatar lngsx avatar myhro avatar nma avatar philippbosch avatar piranha avatar scourou avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

dokku-pg-plugin's Issues

DB automatic unlink

I am using dokku-pg-plugin in combination with a nodejs dokku application. Linking of the database to my dokku nodejs application works fine. But after sometime the nodejs application can no longer reach the postgresql database, relinking the db to the application fixes the issue, but it will resurface again after a while. The application's log or the database's log do not reveal anything about the issue. I am still fairly new to Dokku and Docker so I am not quite sure where to look for the problem behind this issue, is there a way to export all postgresql log messages? I am running Docker 1.6.2 with Dokku v0.3.18 and the latest version of this plugin.

Can't seem to connect to conainer from other container on first run?

Scenario:

  • deploy railsapp
  • i create posgtesql container
  • i link them together
  • i run ssh -i ./data/id_rsa -t [email protected] run pr-what rake db:migrate db:seed

Now the last one blocks. Because that container cant connect to the psql container. The database url is present but it just seems not allowed to connect for some reason.

rake aborted!
could not connect to server: Connection timed out
    Is the server running on host "172.17.42.1" and accepting
    TCP/IP connections on port 49166?
/app/vendor/bundle/ruby/2.1.0/gems/activerecord-4.0.3/lib/active_record/connection_adapters/postgresql_adapter.rb:831:in `initialize'
/app/vendor/bundle/ruby/2.1.0/gems/activerecord-4.0.3/lib/active_record/connection_adapters/postgresql_adapter.rb:831:in `new'
/app/vendor/bundle/ruby/2.1.0/gems/activerecord-4.0.3/lib/active_record/connection_adapters/postgresql_adapter.rb:831:in `connect'
/app/vendor/bundle/ruby/2.1.0/gems/activerecord-4.0.3/lib/active_record/connection_adapters/postgresql_adapter.rb:548:in `initialize'
/app/vendor/bundle/ruby/2.1.0/gems/activerecord-4.0.3/lib/active_record/connection_adapters/postgresql_adapter.rb:41:in `new'
/app/vendor/bundle/ruby/2.1.0/gems/activerecord-4.0.3/lib/active_record/connection_adapters/postgresql_adapter.rb:41:in `postgresql_connection'
/app/vendor/bundle/ruby/2.1.0/gems/activerecord-4.0.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:440:in `new_connection'
/app/vendor/bundle/ruby/2.1.0/gems/activerecord-4.0.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:450:in `checkout_new_connection'
/app/vendor/bundle/ruby/2.1.0/gems/activerecord-4.0.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:421:in `acquire_connection'
/app/vendor/bundle/ruby/2.1.0/gems/activerecord-4.0.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:356:in `block in checkout'
/app/vendor/bundle/ruby/2.1.0/gems/activerecord-4.0.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:355:in `checkout'
/app/vendor/bundle/ruby/2.1.0/gems/activerecord-4.0.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:265:in `block in connection'
/app/vendor/bundle/ruby/2.1.0/gems/activerecord-4.0.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:264:in `connection'
/app/vendor/bundle/ruby/2.1.0/gems/activerecord-4.0.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:546:in `retrieve_connection'
/app/vendor/bundle/ruby/2.1.0/gems/activerecord-4.0.3/lib/active_record/connection_handling.rb:79:in `retrieve_connection'
/app/vendor/bundle/ruby/2.1.0/gems/activerecord-4.0.3/lib/active_record/connection_handling.rb:53:in `connection'
/app/vendor/bundle/ruby/2.1.0/gems/activerecord-4.0.3/lib/active_record/migration.rb:863:in `initialize'
/app/vendor/bundle/ruby/2.1.0/gems/activerecord-4.0.3/lib/active_record/migration.rb:764:in `new'
/app/vendor/bundle/ruby/2.1.0/gems/activerecord-4.0.3/lib/active_record/migration.rb:764:in `up'
/app/vendor/bundle/ruby/2.1.0/gems/activerecord-4.0.3/lib/active_record/migration.rb:742:in `migrate'
/app/vendor/bundle/ruby/2.1.0/gems/activerecord-4.0.3/lib/active_record/railties/databases.rake:42:in `block (2 levels) in <top (required)>'

However when is SSH into the box. Telnet to the PSQL container and i get the PSQL socket listening (thus is running).

After this intial connect, the same command works.

ssh -i ./data/id_rsa -t [email protected] run pr-what rake db:migrate db:seed

What the heck is going on?

It seems like the images running in the container are only to allow to already established connections or something? Its hard to pinpoint the issue.

Passing db login details to newly-deployed apps

Would it be possible / advisable to write the generated db login details to a newly-deployed app, maybe to its filesystem or (like heroku does) to environment variables?

Happy to hack on this, but don't really know where to start...

Rails unable to access through credential...

It's probably a configuration issue, but I fon't know where I can get some help on this.

So here is the issue:

I've created the database using the 'dokku postgres:create gardian' command

I've installed the application container using the gardian name

I see both container using docker ps

I can log to the database using psql with the credential given by the dokku postgres:info command
but my application container can not access it! I have a time out error

Here is the status of a docker -ps during a rake db:migrate attempt

CONTAINER ID        IMAGE                       COMMAND                CREATED             STATUS              PORTS                     NAMES

21e98fc9c45e        dokku/gardian:latest        "/exec bundle exec r   9 seconds ago       Up 8 seconds                                  jovial_hoover
47a17b814535        postgresql/gardian:latest   "/usr/bin/start_pgsq   25 hours ago        Up 25 hours         0.0.0.0:49175->5432/tcp   berserk_bohr        

The rake db:migrate return a time out error complaing that it can not connect?. I've verified several times, and the credential are ok (username, password, host, port, db)

Any help?

jdbc connection attempt failed

I'm deploying a Play Scala application....and I basically tried almost everything, still it keeps feeding me this error:

[ERROR] [08/05/2014 05:10:43.599] [mturk-survey-akka.actor.default-dispatcher-2] [akka://mturk-survey/user/SECCompany] The connection attempt failed.
org.postgresql.util.PSQLException: The connection attempt failed.
    at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:233)
    at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:64)

This is the error that I keep getting. I'm using the correct driver (incorrect at first but I fixed that)

I needed to modify the original connection string into something like this according to JDBC format:

jdbc:postgresql://root:[email protected]:49155/db

However it's still connection attempt failed. I'm running out of solutions, and any tip of what might have gone wrong?

I got the original string from TypeSafe Config file like this: connect = "jdbc:"${?DATABASE_URL}

I also put the username, password, url (IP address doesn't work) into PGCommander (a Mac app), and it can successfully connect to the database! So what's going on!?

Cannot start container : port has already been allocated

After having to restart my VPS, one of the apps can no longer connect to the DB. When running postgresql:link I get the following error:

Cannot start container : port has already been allocated

When running postgresql:info I get the correct settings.

When running postgresql:dump I get:

pg_dump: [archiver (db)] connection to database "db" failed: server closed the connection unexpectedly
This probably means the server terminated abnormally before or while processing the request.

I've tried pretty much everything, including pushing a new version etc. Please advice, as this is urgent and is keeping a production app offline.

seems not working with docker 1.7

dokku postgresql:create db
Your docker version is too old, please update it

dokku postgresql:link web db
docker: "inspect" requires a minimum of 1 argument.
See 'docker inspect --help'.

Usage: docker inspect [OPTIONS] CONTAINER|IMAGE [CONTAINER|IMAGE...]

Assumption that docker0 has IP 172.17.42.1

I'm running a custom bridge:

$ ifconfig docker1
docker1   Link encap:Ethernet  HWaddr 12:ca:5d:a0:5a:b8  
          inet addr:172.20.102.129  Bcast:172.20.102.255  Mask:255.255.255.128
          inet6 addr: fe80::18f3:c4ff:fe5d:85fd/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:25547946 errors:0 dropped:0 overruns:0 frame:0
          TX packets:35766742 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:29239011001 (29.2 GB)  TX bytes:58190725853 (58.1 GB)

So the output isn't quite correct:

$ dokku postgresql:info APP

       Host: 172.17.42.1
       Port: 49155
       User: 'root'
       Password: 'XXXX'
       Database: 'db'

       Url: 'postgres://root:[email protected]:49155/db'

Permission denied when deleteing database

 ssh -t dokku@XXXX postgresql:delete django-test-db
rm: cannot remove ‘/var/lib/docker/vfs/dir/8909e9d5c89c18f3602cec8a20d3ae659432374e33ac43f907d6b2f24fc7b7f5’: Permission denied

Access from the outside?

Hello,
is there a possibility to configure this postgresql plugin to create databases that are accessible from the outside of the server?

I know how to make such thing on debian/ubuntu but i'm not sure where to start when it comes do docker/dokku.

Thanks in advance.

postgresql:link can only connect same-named apps and dbs

Or I expect something which I shouldn't. I expected that dokku postgresql:link appname dbname will connect a database to an app, but looking at sources what it does is rather strange: it checks $3 once, but then uses $APP for everything else, so that $3 is effectively discarded.

Is this a bug or it works as intended and I just don't understand something?

dokku-pg-plugin does not use DOKKU_NOT_IMPLEMENTED_EXIT, leads to misbehaviour with unknown commands

(From dokku/dokku#1156)

In a bare install, if I run a valid command, it displays output and exits with 0 (normally).
(assume dokku-remote is an alias for ssh dokku@....)

➜ ~ dokku-remote apps; echo $?
=====> My Apps
ruby-sample
0

If I give an invalid command dokku helps me with message and exit code.

➜ ~ dokku-remote appsitypo; echo $?
! appsi is not a dokku command.
! See dokku help for a list of available commands.
1

Now if I install a dokku-pg-plugin

cd /var/lib/dokku/plugins
git clone https://github.com/Kloadut/dokku-pg-plugin postgresql
dokku plugins-install

the situation changes for worse:

➜ ~ dokku-remote apps; echo $?
=====> My Apps
ruby-sample
0
➜ ~ dokku-remote appsitypo; echo $?
0

I have not needed that yet, but it might be pretty annoying for scripting-stuff-situations.

postgresql:dump could not change directory to "/root"

Hello. Thank you for plugin.

For me dump command stop working

Here is my observations:

docker version
Client version: 1.5.0
Client API version: 1.17
Go version (client): go1.4.1
Git commit (client): a8a31ef
OS/Arch (client): linux/amd64
Server version: 1.5.0
Server API version: 1.17
Go version (server): go1.4.1
Git commit (server): a8a31ef
dokku version
v0.3.16

In the commands source command looks like:

postgresql:dump)
    ...bla-bla-bla

    pg_dump -h $IP -p $PORT -U root -c -O db

    ...bla-bla-bla

i was try manually run command

       dokku postgresql:info myapp

       Host: 172.17.42.1
       Port: 49154
       User: 'root'
       Password: 'ASJKDHF*Yhdshjkfh'
       Database: 'db'

got it! should be easy

export $PGPASSWORD='ASJKDHF*Yhdshjkfh'
pg_dump -h 172.17.42.1 -p 49154 -U root -c -O db > dump.sql

But, command rejected

pg_dump: [archiver (db)] connection to database "db" failed: could not connect to server: No route to host

Strange? Not after this:

docker ps

dokku/myapp:latest  "/start web"  26 minutes ago gloomy_wright
postgresql/myapp:latest   "/usr/bin/start_pgsq   27 minutes ago  0.0.0.0:49154->5432/tcp   silly_mayer

So, try this and it works

pg_dump -h 0.0.0.0 -p 49154 -U root -c -O db > dump.sql

Who is wrong with $IP ?

cannot connect to plugin after hard restarting server

Rebooting ubuntu from the command line works fine. But hard rebooting the VPS, loses the connection and the only way to reconnect is to create a new database. So basically, any time the system goes down, you lose connection to your database.

Dokku pg with Postgis

Hey @Kloadut,

I'm playing around with Dokku on Digital Ocean and trying to add a rails app that does a few things with postgres' PostGIS add on. Obviously, I was able to install PostGIS on my development machine, but I was wondering if you had any ideas on how to add postgis to the automated postgres docker instances created by your plugin.

Cheers,
Maddi

Invalid DATABASE_URL

When I do a postgresql:create it gives me host, user, database and public port. But not a password, thus the DATABASE_URL created is wrong or can't be filled in completely.

I do get these values, when doing a $ dokku postgresql:create foo:
Host: 172.16.0.104 User: 'root' Database: 'db' Public port: 49187

Any way to set the password manually or why it doesn't give me any password?

There seems to be a password when looking at the output of dokku config glean, but error still exists.

-F/--format option for dump/restore command

sql format could be large and painful to sync between servers.

Since we now have postgresql:console, postgresql:restore probably should use pg_dump's counterpart pg_restore instead of psql

Docker changes container port on restart, app unable to connect to Postgres container

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 in config.yml file. It also works when I manually change DATABASE_URL variable through dokku config:set command.

Possibility to add custom postgresql.conf

The default values of postgresql.conf may have to be modified by user (e.g. max_connections or shared_buffers).
From what I have read about the code of this plugin, it does not allow it yet.
Do you plan to integrate it ? (I am ok to work on it) Or is there a workaround ?

could not connect to server: Connection refused

   Is the server running on host "127.0.0.1" and accepting
   TCP/IP connections on port 5432?
   (PG::ConnectionBad)

No matter what I did including setting the ENV file, I couldn't get away from this problem when trying to deploy my app on digital ocean?
I'm trying to install ruby 2.1.1
I started with the premade digital ocean dokku image.
I don't know whats causing it and although I saw some reference to this problem in the first comment on https://www.digitalocean.com/community/articles/how-to-use-the-dokku-one-click-digitalocean-image-to-run-a-ruby-on-rails-app I couldn't find a solution to this problem that worked for me

Multiple Apps, same database

I have two applications that are supposed to use the same database. Both of these need write access to the full database. This does not seem to be working correctly. I linked both apps to the same database, but I get a Permission Denied for one of them (specifically when it tries to access the hibernate_sequence table).

Is there any way to fix this and make this setup work?

automatically set existing DATABASE_URL for redeploy of linked app

Upon redeploying an app (having previously created a db and linking the existing app to the db) the redeployed app does not have access to the previously set DATABASE_URL. This makes sense because the new container won't have the env vars so my question is what is the preferred way to programmatically set the DATABASE_URL env var for a frequently deployed app?
#23 seems promising but I still can't quite figure out what's going on. Also, this issue from docker seems promising but doesn't appear to automatically set env vars: moby/moby#240

[QUESTION] dumping already existing db ?

Hi!

I have a psql database on my local machine that i would like to use on a dokku Flask app.

However, when i do:

 "dokku postgresql:restore <DOKKU_DB> <OTHER_DB_DUMP"

I get the following log:

could not change directory to "/root": Permission denied
SET
ERROR:  unrecognized configuration parameter "lock_timeout"
SET
SET
SET
SET
CREATE EXTENSION
COMMENT
SET
SET
SET
CREATE TABLE
ERROR:  role "user1" does not exist
CREATE TABLE
ERROR:  role "user2" does not exist
CREATE TABLE
ERROR:  role "user1" does not exist
REVOKE
REVOKE
GRANT
GRANT

Any idea how to create a new user, and why Im getting the permission, config errors?

Error creating a database. "exit" executable not found.

When trying to run the create database command, I get an error.

Error response from daemon: Cannot start container 0392eb18a39a8c13fbee0e32f0261fe82b83dab21416e3b9b550161225282724: exec: "exit": executable file not found in $PATH

I'm running docker 1.1.0 and dokku 2.3

Unable to install the plugin

Upon running the dokku plugins-install command, I get the following output, with none of the related commands working.

gpg: keyring `/tmp/tmpj9d1tn4z/secring.gpg' created
gpg: keyring `/tmp/tmpj9d1tn4z/pubring.gpg' created
gpg: requesting key C300EE8C from hkp server keyserver.ubuntu.com
gpg: /tmp/tmpj9d1tn4z/trustdb.gpg: trustdb created
gpg: key C300EE8C: public key "Launchpad Stable" imported
gpg: no ultimately trusted keys found
gpg: Total number processed: 1
gpg:               imported: 1  (RSA: 1)

Configuration file '/etc/nginx/nginx.conf'
 ==> Modified (by you or by a script) since installation.
 ==> Package distributor has shipped an updated version.
   What would you like to do about it ?  Your options are:
    Y or I  : install the package maintainer's version
    N or O  : keep your currently-installed version
      D     : show the differences between the versions
      Z     : start a shell to examine the situation
 The default action is to keep your current version.
*** nginx.conf (Y/I/N/O/D/Z) [default=N] ? dpkg: error processing package nginx-common (--configure):
 EOF on stdin at conffile prompt
dpkg: dependency problems prevent configuration of nginx-full:
 nginx-full depends on nginx-common (= 1.6.2-2+trusty0); however:
  Package nginx-common is not configured yet.

dpkg: error processing package nginx-full (--configure):
 dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
dpkg: dependency problems prevent configuration of nginx:
 nginx depends on nginx-full (>= 1.6.2-2+trusty0) | nginx-light (>= 1.6.2-2+trusty0) | nginx-extras (>= 1.6.2-2+trusty0); however:
  Package nginx-full is not configured yet.
  Package nginx-light is not installed.
  Package nginx-extras is not installed.
 nginx depends on nginx-full (<< 1.6.2-2+trusty0.1~) | nginx-light (<< 1.6.2-2+trusty0.1~) | nginx-extras (<< 1.6.2-2+trusty0.1~); however:
  Package nginx-full is not configured yet.
  Package nginx-light is not installed.
  Package nginx-extras is not installed.

dpkg: error processing package nginx (--configure):
 dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
Errors were encountered while processing:
 nginx-common
 nginx-full
 nginx
E: Sub-process /usr/bin/dpkg returned an error code (1)

Postgresql is down after server reboot

After i've restarted my server, it seems like dokku forgets all about the postgresql containers. My rails app is giving me the following error:

PG::ConnectionBad (could not connect to server: No route to host
    Is the server running on host "172.17.0.23" and accepting
    TCP/IP connections on port 5432?
):

I've allready tried to recreate the Postgresql container with: dokku postgresql:create APP_NAME but no joy.

-----> Reusing postgresql/REDACTED database
Database is already linked

-----> PostgreSQL container created: postgresql/REDACTED

       Host: 172.17.0.14
       User: 'root'
       Database: 'db'
       Public port: 0.0.0.0:49161

It worked before the reboot.

Plugin freezes Rails app on push

Hi,

I've been experiencing some weird behaviour with this postgres plugin. I've updated to Docker 0.7.4 and when I push my app to the latest dokku, it freezes during the git-receive-hook.

When I remove the postgresql plugin, everything is fine and the app gets deployed.

Does anybody have the same issue?

postgresql:list

Hey,

It would be nice to be able to list existing database containers!

Unable to install

When I run dokku plugins-install, it runs through, and then spits out this at the end:

INFO[0011] The command [/bin/sh -c LC_ALL=C DEBIAN_FRONTEND=noninteractive apt-get install -y -q postgresql-9.3 postgresql-contrib-9.3] returned a non-zero code: 100 

If it try any commands it says: PostgreSQL image not found... Did you run 'dokku plugins-install' ?

Database IP Changes on Server Reboot

I'm running into an issue where the PostgresSQL ip changes on reboot, but it doesn't update the DATABASE_URL env variable with the new IP.

I've resorted to looking up the ip by running dokku postgresql:info www on reboot and the manually updating the DATABASE_URL variable with the new ip.

Obviously this is non ideal and would be problematic if the server go down on its own.

Error on Dokku

Hi,

I'm trying use Dokku on Digital Ocean, but when I try create my database, show this error:

PostgreSQL image not found... Did you run 'dokku plugins-install' ?

root@intersecti:~# dokku help
backup:export [file] Export dokku configuration files
backup:import [file] Import dokku configuration files
config display the config vars for an app
config:get KEY display a config value for an app
config:set KEY1=VALUE1 [KEY2=VALUE2 ...] set one or more config vars
config:unset KEY1 [KEY2 ...] unset one or more config vars
delete Delete an application
help Print the list of commands
logs [-t] Show the last logs for an application (-t follows)
plugins-install Install active plugins
plugins Print active plugins
postgresql:create Create a PostgreSQL container
postgresql:delete Delete specified PostgreSQL container
postgresql:dump > dump_file.sql Dump database data
postgresql:info Display database informations
postgresql:link Link an app to a PostgreSQL database
postgresql:list Display list of PostgreSQL containers
postgresql:logs Display last logs from PostgreSQL container
postgresql:restore < dump_file.sql Restore database data from a previous dump
run Run a command in the environment of an application
url Show the URL for an application
version Print dokku's version

Permission denied when creating database

I'm using the most recent version of dokku (master branch from just minutes ago)

ubuntu@domU-12-31-39-17-2C-E7:~$ sudo dokku postgresql:create politicalframing
mv: accessing ‘/var/lib/docker/vfs/dir/postgresql-politicalframing’: Permission denied

Messing around with the permissions (e.g. changing it to 777) changed nothing.


The https://github.com/teemow/dokku-pg-plugin fork seems to still be functioning.

However, I think it dynamically assigns the IP and upon restarting the server the DATABASE_URL and the postgresql container get out of sync.

Failed to setup container

I have created a database and everything was working just fine. But I needed to reboot the server, the container haven't started up. Looking through the logs i got this

lxc-start: No such file or directory - failed to mount '/var/lib/docker/volumes/8831ff6fd2920c1eff41482b575060584cfbbd466693c6ca9ad253d5014ea589/layer' on '/usr/lib/x86_64-linux-gnu/lxc///opt/postgresql'
lxc-start: failed to setup the mount entries for '59d188d2fcc8756b54c6c2f6eb62d00c7d969f06bd26bc7b9b1014e95bfb18c8'
lxc-start: failed to setup the container
lxc-start: invalid sequence number 1. expected 2
lxc-start: failed to spawn '59d188d2fcc8756b54c6c2f6eb62d00c7d969f06bd26bc7b9b1014e95bfb18c8'

Any idea on why this happened?

Postgresql db created without password. Can't connect!

After having trouble with #2 after booting, I removed all containers from docker and the images that I created before (both the node app as well as the postgresql container). I recreated the container using:

dokku postgresql:create sequelize-app

This worked except the info didn't show any password, ever:

root@Pudge:~# dokku postgresql:info sequelize-app

   Host: 172.17.0.30
   User: 'root'
   Database: 'db'
   Public port: 0.0.0.0:49160

After pushing the node application, the container (with the node app) exits writing into the logs:

Error: Failed to find PostgresSQL server. Please double check your settings.,

It does seem to have a password set in the environment variable though:

postgres://root:[email protected]/db

Still the connection cannot be made. I ran /bin/bash for the postgres container and checked for the postgressql service status, noticed it was down. Trying to start yields an error:

root@836e7b8ae89a:/# /etc/init.d/postgresql start 
* Starting PostgreSQL 9.1 database server
* Error: /opt/postgresql/9.1/main is not accessible or does not exist

How come the service is down in the first place within the container and how come I can't start it? Or am I lacking some understanding of how docker is supposed to work? (I'm quite new to this)

UPDATE: I read this blog post about Docker and Postgres and tried to connect to the db in the running container with psql. I can connect to the DB with the same password my node application seems to get, so I really wonder what the problem is... If I run /bin/bash with the node app image and try to ping the ip, I get a response. So the IP works (I think), credentials are correct, but something is still wrong.

UPDATE 2: I just realized that the IP's are not actually the same. postgresql:info yields ...30 while process.env.DATABASE_URL contains ....25. 30 is pingable while 25 is not, so that's got to be the problem. Not sure why the two IP addresses not match though.

No such port directory in .postgresql

I get an error message regards to postgresql when i run git push dokku master

remote: cat: /home/dokku/.postgresql/port_myappname: No such file or directory To dokku@myipaddress:myappname ! [remote rejected] master -> master (pre-receive hook declined) error: failed to push some refs to 'dokku@myipaddress:myappname'

I linked postgresql database with the app through dokku postgresql:link appname databasename

Any idea how it can be fixed?

Host and Port information are missing

For some reason dokku seems to have forgotten my Host and Port information.

When I execute

dokku postgresql:info

I get:


docker: "inspect" requires a minimum of 1 argument.
See 'docker inspect --help'.

Usage: docker inspect [OPTIONS] CONTAINER|IMAGE [CONTAINER|IMAGE...]

Return low-level information on a container or image
json: cannot unmarshal array into Go value of type struct { NetworkSettings struct { Ports nat.PortMap } }

       Host:
       Port:
       User: 'root'
       Password: '<redacted>'
       Database: 'db'

       Url: 'postgres://root:<redacted>@:/db'

When I try to start up my rails app I get:

URI::InvalidURIError: the scheme postgres does not accept registry part: root:<redacted>@<redacted>:32769: (or bad hostname?)

This all worked yesterday, and I can connect to the database using the credentials above, but when I tried to update my dokku version this started happening.

Dokku v0.3.18-80-gc0f8764
dokku-pg-plugin 35edfeb

Any help would be greatly appreciated!

Multiple Databases, crossover?

I have two apps (staging and www), created two ps databases (confirmed separate ports and separate passwords), each linked to the specifc app (staging or www). I presume that it is actually two separate databases, but when I make an entry in www, it also shows up in staging. Am I missing something?

dump command available when postgresql-client not installed

Hi,

it would be convenient if the plugin installs postgresql-client or hides the dump command if it is not found. The error message is helpful already, but proposed changes would ease things up a bit.

I assume same is true for the restore command.

Thanks for your work,

felix

Installing the PG plugin is failing

When i follow the install steps, by cloning in the /var/lib/dokku/plugins folder, and run the command dokku plugins-install i get the following error:

gpg: keyring `/tmp/tmppvhc7u/secring.gpg' created
gpg: keyring `/tmp/tmppvhc7u/pubring.gpg' created
gpg: requesting key C300EE8C from hkp server keyserver.ubuntu.com
gpg: /tmp/tmppvhc7u/trustdb.gpg: trustdb created
gpg: key C300EE8C: public key "Launchpad Stable" imported
gpg: no ultimately trusted keys found
gpg: Total number processed: 1
gpg:               imported: 1  (RSA: 1)
2014/01/04 14:32:52 Error: Error build: archive/tar: invalid tar header

When i remove the PG plugin, and run dokku plugins-install again, no errors.

Rails database.yml file not parsing correctly

I am using Dokku v0.3.15 + Ubuntu v14.

Creating a new db through the plugin appears to be generating an correct DATABASE_URL with the latest from master branch.

[email protected]#: dokku postgresql:link myapp myappdb
docker: "inspect" requires a minimum of 1 argument. See 'docker inspect --help'. 
time="2015-03-22T19:50:08-04:00" level="fatal" msg="json: cannot unmarshal array into Go value of type map[string]interface {}" 
-----> Creating /home/dokku/app/ENV 
-----> Setting config vars and restarting app 
DATABASE_URL: postgres://root:XXXXXXX@:/db 
-----> Releasing app ... 
-----> Release complete! 
-----> Deploying app ... 
-----> Deploy complete!

(Notice missing hostname.)

So when I ran a db:migrate, I got a URI::InvalidURIError (something to the effect of http://stackoverflow.com/questions/29071069/dokku-rails-postgresql-error-uriinvalidurierror-the-scheme-postgres-doe).

Luckily, I had an older version of the dokku-pg-plugin (I suppose you could check out an earlier commit), so I manually installed the older plugin and it works:

local$ scp postgresql.tar [email protected]:/var/lib/dokku/plugins/
[email protected]#: cd /var/lib/dokku/plugins/
[email protected]#: tar xf postgresql.tar
[email protected]:/var/lib/dokku/plugins# dokku postgresql:link myapp myappdb
time="2015-03-22T20:22:33-04:00" level="fatal" msg="json: cannot unmarshal array into Go value of type map[string]interface {}" 
-----> Setting config vars and restarting app
       DATABASE_URL: postgres://root:[email protected]:/db
-----> Releasing app ...
-----> Deploying app ...
-----> Running pre-flight checks
       check-deploy: /home/dokku/app/CHECKS not found. attempting to retrieve it from container ...
       CHECKS file not found in container. skipping checks.
-----> Running post-deploy
-----> Configuring app.leverage.blue...
-----> Creating http nginx.conf
-----> Running nginx-pre-reload
       Reloading nginx
-----> Shutting down old container in 60 seconds
=====> Application deployed:
       http://myapp.example.com

(Notice hostname appears correctly.)

Has something changed in the DATABASE_URL generation logic that causes hostname to go astray?

Thank you!

Unicode

I'm trying out Dokku for the first time, and everything seems to be running smoothly except or Unicode support. I've run into this error before with standard installs, but since this is utilizing Docker, I'm not sure how this should be handled:

PG::InvalidParameterValue: ERROR: new encoding (UTF8) is incompatible with the encoding of the template database (SQL_ASCII)

I'm using Digital Ocean's Dokku image, which is currently running v0.3.17 and the latest master of this plugin. Any ideas? All of the documentation that I've seen seems to show Unicode working out of the box, but it looks like my Postgres was set up with ASCII.

Edit: I was able to switch template1 to UTF8 using postgresql:console, but this feels wrong as I'm assuming I'll have to do it with each app.

Recovering from crash

So I've got this plugin running on a DigitalOcean. I Power Cycled the instance on accident. Now my app won't start at all. Here's the output on pushing to the DO instance.

Counting objects: 4, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 368 bytes | 0 bytes/s, done.
Total 4 (delta 3), reused 0 (delta 0)
-----> Cleaning up ...
-----> Building APP_NAME_REDACTED ...
remote: Cloning into '/tmp/tmp.wC88GqdTqf'...
remote: done.
remote: HEAD is now at fc1c707... shit
       Python app detected
-----> Installing dependencies with pip
       Cleaning up...
-----> Discovering process types
       Procfile declares types -> web
-----> Releasing APP_NAME_REDACTED ...
-----> Deploying APP_NAME_REDACTED ...
-----> Checking status of PostgreSQL
       Found image postgresql/APP_NAME_REDACTED database
       Checking status... stopped.
remote: cat: /home/dokku/.postgresql/volume_APP_NAME_REDACTED: No such file or directory
To dokku@IP_ADDRESS_REDACTED:APP_NAME_REDACTED
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'dokku@IP_ADDRESS_REDACTED:APP_NAME_REDACTED'

Note that the database name is not APP_NAME_REDACTED, but actually APP_NAME_REDACTED-db. Also, ll in /home/dokku/.postgresql gives this:

total 16
drwxr-xr-x 2 dokku dokku 4096 Nov 10 11:45 ./
drwxr-xr-x 6 dokku root  4096 Oct  4 23:48 ../
-rwx------ 1 dokku dokku   17 Oct  9 00:01 pwd_APP_NAME_REDACTED-db*
-rw-r--r-- 1 dokku dokku   89 Oct  9 00:01 volume_APP_NAME_REDACTED-db

My instance has 512 mb of ram.

broken installation

It may be reproduce easily on digital ocean folowing this tutorial:

https://www.digitalocean.com/community/tutorials/how-to-use-the-dokku-one-click-digitalocean-image-to-run-a-ruby-on-rails-app

the installation of postgresql is broken

root@railsdokku:/var/lib/dokku/plugins# dokku plugins-install
gpg: keyring /tmp/tmpnl0mecnn/secring.gpg' created gpg: keyring/tmp/tmpnl0mecnn/pubring.gpg' created
gpg: requesting key C300EE8C from hkp server keyserver.ubuntu.com
gpg: /tmp/tmpnl0mecnn/trustdb.gpg: trustdb created
gpg: key C300EE8C: public key "Launchpad Stable" imported
gpg: no ultimately trusted keys found
gpg: Total number processed: 1
gpg: imported: 1 (RSA: 1)
Cloning into '/tmp/dokku-pg-dockerfiles'...
remote: Reusing existing pack: 61, done.
remote: Total 61 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (61/61), done.
Checking connectivity... done.
Sending build context to Docker daemon 137.7 kB
Sending build context to Docker daemon
Step 0 : FROM ubuntu:quantal
Pulling repository ubuntu
c5881f11ded9: Download complete
511136ea3c5a: Download complete
bac448df371d: Download complete
dfaad36d8984: Download complete
5796a7edb16b: Download complete
---> c5881f11ded9
Step 1 : MAINTAINER kload "[email protected]"
---> Running in ff0ec3117846
---> 86c38326639b
Removing intermediate container ff0ec3117846
Step 2 : RUN echo "#!/bin/sh\nexit 101" > /usr/sbin/policy-rc.d; chmod +x /usr/sbin/policy-rc.d
---> Running in cb94545d00f2
---> 0023a8485955
Removing intermediate container cb94545d00f2
Step 3 : RUN apt-get update
---> Running in 986ffdc3e1fc
2014/07/16 07:19:16 The command [/bin/sh -c apt-get update] returned a non-zero code: 100
root@railsdokku:/var/lib/dokku/plugins#

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.