0
votes

I've created a docker postgis container with the following command :

docker run -p 5435:5432  -e POSTGRES_PASSWORD=xxxxxxx -e POSTGRES_INITDB_ARGS="-d" mdillon/postgis:9.6

This created a volume for data in /var/lib/docker/volumes/[some_very_long_id]/_data

Now I need to move this volume to somewhere else to ease backup for my outsourcing contractor... and don't know how to do this. I'm a bit lost as there seems to be different alternative with data volumes and fs mounts for example.

So what's the correct way to do it as today ? And how to move my current data directory to a better place ?

Thanks.

2

2 Answers

3
votes

You can declare a volume mount when you run your container. For example, you could run your container like this:

docker run -p 5435:5432 -e POSTGRES_PASSWORD=xxxxxxx -e POSTGRES_INITDB_ARGS="-d" \
-v /the/path/you/want/on/your/host:/var/lib/postgresql/data \
mdillon/postgis:9.6

This way the postgres data directory will be in the /the/path/you/want/on/your/host in your host.

1
votes

I didn't check or search deeply, but in your case I suggest to do following step:

  1. Create another container with outside folder.
  2. Using pg_basebackup get all data from the old container to the new container. Or using replicate.

So, you have the data folder outside the container.

Hopefully it will help your case.