How to dump PostgreSQL database from one docker container to another?

0 like 0 dislike
112 views
Good day, I tips on how to make a PostgreSQL database dump from one container to another?
I sketched the code and I was able to do only in a separate file, and directly into the container to fill?
docker run --name dbdata postgres echo "Data-only container for postgres" # Create our containers docker run-d --volumes-from dbdata --name db1 postgres # Apply the argument to the first container --volumes-from docker run-d --volumes-from dbdata --name db2 postgres # Apply the argument to the second container with --volumes-from docker exec-i-t db1 bash #Podklyuchaetsya to the first container docker exec-i-t db2 bash #Podklyuchaetsya to the second container apt-get update; apt-get install sudo # Update and install sudo sudo-i -u postgres # Go to the postgresql database createdb my_db #create our database docker exec db1 pg_dump -U postgres -F t my_db > my_db-$(date +%Y-%m-%d).tar.gz # Do a dump of the database in the file
by | 112 views

1 Answer

0 like 0 dislike
so if you --volumes-from dbdata use the same, you have a disk mounted in both container, and therefore, this file just needs to be available in another container.

The only question is where the data you store? directly into primenenem volume?
by

Related questions

0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
2 answers
110,608 questions
257,187 answers
0 comments
40,796 users