Answer the question
In order to leave comments, you need to log in
How to dump postgressql database from one docker container to another?
Good afternoon, I ask for tips on how to dump the postgressql database from one container to another?
I sketched out the code and I managed to make it only into a separate file, but how can I pour it directly into the container?
docker run --name dbdata postgres echo "Data-only container for postgres" # Создаем наши контейнеры
docker run -d --volumes-from dbdata --name db1 postgres # Применяем аргумент для первого контейнера --volumes-from
docker run -d --volumes-from dbdata --name db2 postgres # Применяем аргумент для второго контейнера --volumes-from
docker exec -i -t db1 bash #Подключчаемся к первому контейнеру
docker exec -i -t db2 bash #Подключчаемся ко второму контейнеру
apt-get update; apt-get install sudo # Обновим и установим sudo
sudo -i -u postgres # Заходим в бд postgresql
createdb my_db #создаем нашу базу данных
docker exec db1 pg_dump -U postgres -F t my_db > my_db-$(date +%Y-%m-%d).tar.gz # Делаем дамп базы данных в фаил
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question