0

I have a data only postgresql container

docker create -v /var/lib/postgresql/data --name bevdata mdillon/postgis /bin/true

I have a running Postgis container

docker run --name bevaddress -e POSTGRES_USER=bevsu -e POSTGRES_DB=bevaddress -P -d --volumes-from bevdata mdillon/postgis

I have made a backup of that database into the bavaddress container into directory /var/lib/postgresql/backup

I think this means that the backup data is in container bevaddress (the running process) and NOT the data only container bevdata which I think is good.

Now if I docker pull mdillon/postgis to a new version, how can I attach the folder /var/lib/postgresql/backup of container bevaddress so that a new instance and version of mdillon/postgis can access that folder to restore the database?

1 Answer 1

2

To the best of my knowledge, you cannot. The file system in your running container only exists for the duration of the run. Without mounting a volume, you have no way to allow a second container access to the backup.

For future backups, you could create a second volume only container that mounts /var/lib/postgresql/backup.

Sign up to request clarification or add additional context in comments.

1 Comment

That's the solution I also came up with. Unfortunaltey it forces you to think in advance to add that second backup volume the moment you issue docker run. Later on it seems either impossible to do so (no way to add volume by docker start). Adding volumes in advance for backup/migration tasks should be at least described as a good practice.

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.