When following the deployment guide, I run into a docker error

Florian Kohrt Public Seen by 169

Now I believe this is not a problem with Loomio but arises due to my lack of knowledge about docker (and docker-compose). But when I followed the deployment guide over at https://github.com/loomio/loomio-deploy I came to to step wher the following had to be executed:
docker exec -ti loomio-db su - postgres -c 'createdb loomio_production'
Running this as sudo fails with the message: Error: No such container: loomio-db
I believe there's something easy I can do to resolve this, but following the guide lead to it. Do you have an idea what I can do?


Rob Guthrie Thu 2 May 2019

Hi @fkohrt,

This is because the container is not running, how about if you run:

docker-compose run db su - postgres -c 'createdb loomio_production'

Please let me know if that works.


Florian Kohrt Thu 2 May 2019

Thanks for the reply, @robertguthrie

Not as it should, I believe. The response was:
createdb: could not connect to database template1: could not connect to server: No such file or directory
Is the server running locally and accepting connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?


Rob Guthrie Fri 3 May 2019

that's odd. What if you do

docker-compose run db;
docker exec -ti loomio-db su - postgres -c 'createdb loomio_production'


Florian Kohrt Sun 5 May 2019

The following log is being displayed if I enter the first line and the command does not terminate:

LOG: database system was interrupted; last known up at 2019-05-05 19:31:37 UTC
LOG: database system was not properly shut down; automatic recovery in progress
LOG: redo starts at 0/14EEEB0
LOG: invalid record length at 0/176D5D0: wanted 24, got 0
LOG: redo done at 0/176D5A8
LOG: last completed transaction was at log time 2019-05-05 19:32:26.641671+00
LOG: MultiXact member wraparound protections are now enabled
LOG: database system is ready to accept connections
LOG: autovacuum launcher started

When I enter the second line in another console, the same error as before appears. If I Ctrl-C the first running command, it says:

^CLOG: received fast shutdown request
LOG: aborting any active transactions
LOG: autovacuum launcher shutting down
LOG: shutting down
LOG: database system is shut down

I do prepend sudo to all commands.


Rob Guthrie Sun 5 May 2019

Right, sorry, let's add a -d so the first command runs in the background. You may need to wait a minute before running the second command.

docker-compose run db -d;
docker exec -ti loomio-db su - postgres -c 'createdb loomio_production'

Florian Kohrt Mon 6 May 2019

The first command lead to
postgres: option requires an argument -- 'd'
so I changed it to

docker-compose run -d db;

I waited a few minutes, but after running the second command it still said Error: No such container: loomio-db

There is a second command that is to be run according to the deploy guide for initializing the database: docker-compose run app rake db:setup
If I run that, the first thing it says is (other error messages followed)

Creating loomio-db ... done

so I guess the docker exec command you're proposing can't be successful before running that once? What can I do, I will clean my environment (delete docker containers and the directory) and start again?


Rob Guthrie Mon 6 May 2019

Sorry, I should have written:

docker-compose up db -d;

docker exec -ti loomio-db su - postgres -c 'createdb loomio_production'


Florian Kohrt Mon 6 May 2019

Dear @robertguthrie, thanks a lot, this solved the issue!