Some upright vacuums and canisters use bags, some collect dirt in a bin. Bag-type vacuums tend to hold more dirt, and emptying them releases less dust into the air. An indicator that tells you when the bag or bin is full reminds you to empty the dirt before it impairs cleaning.
With bagless vacuums you can save money by not having to buy bags, but they still use filters (such as HEPA filters) that need to be periodically cleaned or replaced. Replacement filters tend to be significantly more expensive than bags. Another caveat: Emptying the dustbin and cleaning a filter can be messy, and handling it can expose you to dust and other allergens.
Bagless vacuums save on the cost of bags but they still require filters and need periodic cleaning and–for HEPA filter–replacing. And the dust and mess of emptying their bins is a concern if you have asthma or allergies, though even bags must be handled gently.