docker exec CONTAINER_NAME_OR_ID sh -c 'exec mysqldump --databases DATABASE_NAME -uUSER -pPASSWORD' > backup.sql
docker exec -i CONTAINER_NAME_OR_ID sh -c 'exec mysql -uUSER -pPASSWORD DATABASE_NAME' < backup.sql
Notice "-i" opiton in the import command. It allows to STDIN contents of the dumped sql file inside the container.