use docker exec with the flag -it: general structure is: docker exec -it <container_name> mysql -u<root> -p<password>
docker exec -i some_mysql_container mysql -uroot -ppassword <<< "select database();"