October 6, 2020 at 12:00 am
Comments posted to this topic are about the item Experimenting with PostgreSQL in a Container
October 6, 2020 at 8:15 am
Worth mentioning the -v switch for the docker run command to get a persistent volume.
-v $HOME/docker/volumes/postgres:/var/lib/postgresql/data
It will be slightly different for Windows, the code switch above is on my works MacBook.
If I connected to my container I would find the postgres data files in /var/lib/postresql/data/
The other thing I have found useful is the --network switch for when I have a Python app in a docker container that needs to talk to PostGres in a docker container.
docker network create pg_net
docker run --rm --name pg-docker --network pg_net -d -p 5432:5432 -v $HOME/docker/volumes/postgres:/var/lib/postgresql/data postgres
One thing to watch out for is PostGres versions. PostGres 13 has just been released. I'd been working on my local container for a while on Version 12 and, following a reboot, my database became unavailable. Turns out you PostGres13 cannot read PostGres12 data files without some messing around. fortunately the DB scripts were all under source control so a rebuild from scratch took seconds.
October 6, 2020 at 2:38 pm
Thanks,
I decided not to persist the volume here, precisely because everything is in the VCS and I didn't anticpate this living long. The data isn't important here.
I also did use the networking features because I wanted to run pgadmin in a container as well and need to connect.
October 9, 2020 at 4:10 pm
I appreciate the overview. I hadn't considered pulling in a docker image to play around w/ postgresql, but that makes sense.
I did want to note that the command to pull is for "postgres", not "postgresql". Was trying to figure out what I was missing when it wouldn't pull.
This will be helpful to play around with the engine without having a lot of extra overhead.
October 9, 2020 at 4:38 pm
Thanks, I think I've gotten used to typing postgresql too often.
container are my go to now, to avoid installing more software that might change behavior. I keep thinking I ought to resubscribe to Turbo and get GUI containers for apps, but that didn't work as well because some of these updates too often and the container is always behind.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply