How to make object move but stay within another object?
this is what you need to setup:

all the involved objects (plane, cylinder, toruses) must have rigid body enabled (to calculate gravity and collisions)
plane and cylinder must be passive, toruses active (they're moving)
all involved objects MUST have all transform applied

Plus, all objects (except plane perhaps) need to have the 'mesh' shape type setting, as shown in the picture. When you need to precisely evaluate complex geometries this is the best setting.
example:

then play the animation to get this: