0

I am running a docker-compose project in a DigitalOcean Docker droplet.

I also have a persistent volume. It has been mounted on /mnt/volume_fra1_01

In my docker-compose.yml, I defined the volume for the database:

...

db:
    image: postgres:12.0-alpine
    volumes:
      - postgres_data:/var/lib/postgresql/data/
    env_file:
      - ./postgres/.env

...

volumes:
  postgres_data:

...

and I've created the symbolic link with sudo ln -s /mnt/volume_fra1_01 postgres_data

But I the database is not persistent. When I purge the containers the database is gone. Somehow /var/lib/postgresql/data/ is not using the mounted volume.

0

2 Answers 2

0

when you write this :

- postgres_data:/var/lib/postgresql/data/

postgres_data is a named volume. not a local folder. Is this what digital ocean told you to do ?

can you try with this :

- ./postgres_data:/var/lib/postgresql/data/
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks. But this way it returns 502 Bad Gateway when trying to access the administration area (and presumably with all accesses to the database)
0

Can you try to configure your volumes without the symbolik link :

volumes:
  - /mnt/volume_fra1_01:/var/lib/postgresql/data/

Should work.

1 Comment

Thanks for the suggestion but it does not work: db: forward host lookup failed: Unknown host

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.