Answer the question
In order to leave comments, you need to log in
How to run script in container via docker-compose?
Hello!
I am learning docker-compose. I'm looking for a way to dump a database from a container. Let's say we have docker-compose.yml:
postgres:
image: postgres:9.5
volumes_from:
- postgres-data
volumes:
- ./dump:/backup
postgres-data:
image: busybox
volumes:
- /var/lib/postgresql/data
docker exec _name_ sh -c "cd /var/lib/postgresql/data && tar cf /backup/postgres.tar ."
I get a dump. But this is not very beautiful, especially when a lot of containers are running. Answer the question
In order to leave comments, you need to log in
Quite a working way. But you need to understand that without stopping postgresql, you can easily get inconsistent data in a way from which you will not recover anything. But in fact, I would rather create a separate container that would start with postgres-data and ./dump mounted and do only backups.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question