E
E
Elena2018-08-29 20:11:15
SQL
Elena, 2018-08-29 20:11:15

Docker and uploading large sql files?

In migrations, you have to load large sql files. I found a command to speed up this process:

cat test.sql | docker exec -i name_container_db_host_1 psql -U name_user -d name_db

In this case, the command is run in the directory where this file is located.
But it's still long. Found another command:
docker exec -i name_container_db_host_1 psql -U name_user -d name_db -f test.sql

As I understood it should be faster. But here is the problem with the path to the file. I can't figure out which one is needed. And in this form it says that the file was not found.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
chupasaurus, 2018-08-29
@chupasaurus

In order for the container to see the file in the second command, it (the file) must be placed in an already existing bind mount (in the case of PG, this is usually the host directory into which it is mapped in the container /var/lib/postgresql/data), there are no other ways.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question