News for hackers. Stuff that matters.
Re:Docker orchestration by mikewhy on Monday February 09, 2015 @11:40AM (#9022060)
> It is fucki*ng hard to create a postgres database without using psql or connect directly to the database.

well ideally you would have a script to create the DB and possibly migrate it. IE this will create a PG database from `DATABASE_URL`

    import dj_database_url
    import psycopg2
    from psycopg2.extensions import ISOLATION_LEVEL_AUTOCOMMIT

    config = dj_database_url.config()
    db_conn = psycopg2.connect(host=config['HOST'],
        port=config['PORT'],
        user=config['USER'],
        password=config['PASSWORD'])
    db_conn.set_isolation_level(ISOLATION_LEVEL_AUTOCOMMIT)

    db_cur = db_conn.cursor()
    db_cur.execute('CREATE DATABASE ' + config['NAME'])

    db_cur.close()
    db_conn.close()
then it's simply a matter of `fig up` + `fig run web python manage.py createdb`
Re:Docker orchestration by kdomanski on Tuesday February 10, 2015 @11:03AM (#9027968)
Not even that is necessary.

> The best solution probably is to create a new database during image creation, but in the official Postgres image this option is still not available.

The official image's README (https://registry.hub.docker.com/_/postgres/) says otherwise - both a user and a database will be created with name $POSTGRES_USER (if set).

Furthermore, one can run postgres in single-user mode to prepare any initial db image on top of the official one.