Hi and welcome to NethServer Community,
it should work using the following command:
runagent -m nextcloud1 podman exec -i nextcloud-db mysql -u nextcloud -pnextcloud nextcloud < olddatabase.sql
See also Run mysql inside roudcube container - #3 by mrmarkuz and Howto manage or customize NS8 podman containers for more info.