Ubuntu install, can I install on one computer, then move the drive to another computer to use it?

Was curious if I could install Ubuntu on one computer, then pull the hard drive out and put it into another computer to use it?

Reason is the other computer doesn’t have a CD player or a floppy drive.

So just curious if anyone has tried this method, and if ubuntu does work or if it requires a lot of tinkering to get it running since it was installed one on machine and actually booting and running on another.

Any thoughts are appreciated.