As it's a VM you should be fine as long as there's enough resources for it to run its own docker instance. You just have to give it permission to control docker in the VM. And of course the VM must have docker.
Edit: it's also possible to give it power over a remote docker instance as well. So you could do docker on the host PC and Nextcloud can manage it from the VM.