Skip to content

Permission Issue with db-init Service in Docker Compose #62

@sawakaga

Description

@sawakaga

Hello Maintainers,

Environment:
Docker compose version: Docker Compose version v2.24.5-desktop.1
System: MacOS 14.2.1 (23C71)
Last Commit when bug happen: 084d188

Steps to Reproduce:

  1. Clone the repository from the main branch.
  2. Execute yarn install.
  3. Copy and paste configurations into the config folder.
  4. Run docker-compose up.
  5. Observe the error during the startup of the db-init-1 service.

Expected Behavior:
The db-init-1 service initializes the database without permission errors.

Actual Behavior:
The db-init-1 service fails with the following permission error for several files:

db-init-1  | chown: changing ownership of '/var/lib/postgresql/data/._pg_subtrans': Operation not permitted

Additional Information

After investigating the problem, I found that official postgres docker image README has a part for using arbitrary user usage for postgres.

$ docker volume create pgdata
$ docker run -it --rm -v pgdata:/var/lib/postgresql/data -e POSTGRES_PASSWORD=mysecretpassword postgres
The files belonging to this database system will be owned by user "postgres".
( once it's finished initializing successfully and is waiting for connections, stop it )
$ docker run -it --rm -v pgdata:/var/lib/postgresql/data bash chown -R 1000:1000 /var/lib/postgresql/data
$ docker run -it --rm --user 1000:1000 -v pgdata:/var/lib/postgresql/data postgres
LOG:  database system was shut down at 2017-01-20 00:03:23 UTC
LOG:  MultiXact member wraparound protections are now enabled
LOG:  autovacuum launcher started
LOG:  database system is ready to accept connections

This guide solves the problem.

P.S

On db.yml, stats.yml and docker-compose.yml, db-init services commented out

IMHO

My take on this bug is, db-init does not allow db to initialise before runs the "sh -c chown ***" command.

Probably, it is something different causes the bug but above solution helped me out to proceed. Step-by-step guide on the README currently stuck at second step.

I hope it helps.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions