Skip to content

Problems using 'exec', and interacting with postgres #116

Open
@jkhartshorne

Description

@jkhartshorne

I'm having difficulty using compose.exec. Part of this is because I think the docs are wrong. Here's what docs say:

exec(container, command, options)

However, you definitely have to include information about the docker-compose.yaml. This at least runs:

compose.exec('test_db', psql, {cwd: path.join(initDir, 'pushkin'), config: 'docker-compose.dev.yml'}, '-U postgres', -c 'create database test_db')

However, I get the following error:

'psql: FATAL: role "root" does not exist\n'

So it looks like the -U tag is being ignored. I also tried doing it this way:

compose.exec('test_db', psql -U postgres -c 'create database test_db', {cwd: path.join(initDir, 'pushkin'), config: 'docker-compose.dev.yml'})

with the same result. Here's the critical part of my docker-compose:

test_db:
image: 'postgres:11'
environment:
POSTGRES_PASSWORD: example

Since I didn't set a root user, docker goes with the default 'postgres'. However, trying to set the user to 'root' didn't help:

test_db:
image: 'postgres:11'
environment:
POSTGRES_USER: root
POSTGRES_PASSWORD: example

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions