I am learning with docker containers and I'd like to pass .sql file to database using docker exec. How can I do that? I am searching for about an hour now and found this:
cat file.sql | docker exec -it mariadb sh -c 'mysql -u<user> -p<pass>'
or this
docker exec -it mariadb sh -c 'mysql -u<user> -p<pass> "$(< /path/file.sql)"'
but neither of it worked. I think there is problem that I am passing it into sh -c and it tries to load that file from inside the container. How can I do it?