PostgreSQL Custom Docker Image With Volume Entrypoint Questions
Anonymous
TRIALOP

a year ago

Hello, I have a Docker Image for PSQL with a volume attatched to that service that I am trying to run, on initial startup however, I get the following: PostgreSQL Database directory appears to contain a database; Skipping initialization. How can I have a volume attached but still get this to run? Thanks!

14 Replies

Anonymous
TRIALOP

a year ago

b2136db9-ae75-4237-ac77-4e079154cc94


brody
EMPLOYEE

a year ago

please add more context


Anonymous
TRIALOP

a year ago

Dockerfile:

Docker Compose:

Volume is mounted at /var/lib/postgresql/data
PGDATA is currently set at /var/lib/postgresql/data/pgdata


brody
EMPLOYEE

a year ago

railway services can not have two volumes


Anonymous
TRIALOP

a year ago

Gotcha


Anonymous
TRIALOP

a year ago

What approach would you recommend here?


brody
EMPLOYEE

a year ago

your dockerfile would need to copy the docker-entrypoint-initdb.d file into the applicable location


Anonymous
TRIALOP

a year ago

Okay makes sense, thanks!


brody
EMPLOYEE

a year ago

but even so, its a init script and will not be ran on every redeploy, it will only be ran if there is an empty data volume


Anonymous
TRIALOP

a year ago

Yeah that's fine. I'm assuming adding a volume is the only way to persist data in a Railway service? Or will it do it by default?


brody
EMPLOYEE

a year ago

you are correct, volumes are the only way to persist files on disk


brody
EMPLOYEE

a year ago

can you add some more context though? what does docker-entrypoint-initdb.d do?


Anonymous
TRIALOP

a year ago

Just creates some tables and sets up permissions. I only need it on the original creation of the DB


brody
EMPLOYEE

a year ago

then yeah, copy it into the correct location, and then wipe the volume to allow it to run again


Loading...