3

I'm attempting to run the following command on Mac OSX:

docker run --rm --name kong-database \
    --network=kong-net \
    -v /Volumes/docker/postgres:/var/lib/postgresql/data \
    -p 5432:5432 \
    -e "POSTGRES_USER=kong" \
    -e "POSTGRES_DB=kong" \
    postgres:9.6

With the intention that it will launch postgres in in a docker container, and persist the database data on my local file system in /Volumes/docker/postgres. However, I get the following error, and the container fails to run:

chown: changing ownership of '/var/lib/postgresql/data': Operation not permitted

Any idea what I can do to get this going?

2 Answers 2

5

Turns out that /Volumes was owned by root. When I switched this to something like /Users/JoshuaErney/Volumes, this ran successfully. Here's an example:

docker run --rm --name kong-database \
    --network=kong-net \
    -v /Users/JoshuaErney/Volumes/docker/postgres:/var/lib/postgresql/data \
    -p 5432:5432 \
    -e "POSTGRES_USER=kong" \
    -e "POSTGRES_DB=kong" \
    postgres:9.6
Sign up to request clarification or add additional context in comments.

Comments

1

Answer by jerney is correct, here is what it looks like with docker-compose.yaml:

services:
  test-postgres-compose :
    ...
    volumes :
      - pgdata:/var/lib/postgresql/data
...
volumes :
  pgdata :

Docker compose volumes info

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.