I recently needed to take a mysql database export from one docker container and import it into a different docker container. It took a while to get the commands I needed, with this stackoverflow thread helping me to understand what needed to be done.
I initially tried to use docker exec -it <container> /bin/bash but when I tried to pipe a mysqldump to a mysql to another container I kept getting cannot attach stdin to a TTY-enabled container because stdin is not a terminal
I tracked that down to the -t option of docker exec. Once I removed that I was able to pipe the dump successfully!
sudo docker exec -i <SOURE_MYSQL_CONTAINER> mysqldump -u <USER> -p<PASSWORD> <DATABASE_TO_DUMP> | sudo docker exec -i <DESTINATION_MYSQL_CONTAINER> mysql -u<DESTINATION_DATABASE_USER> -p<DESTINATION_DATABASE_PASSWORD> <DESTINATION_DATABASE>