CountryClover
That could depend on the variety of rosemary. The large shrubs won't do as well in containers long-term, but there are dwarf varieties. Here's a 2-minute video that describes three small ones:
https://youtu.be/qSCtFYyuIgE?s...
However, the MOST important factor is your potting medium. Peat-based water-retentive mixes will kill your rosemary in record time. They hate wet feet. Find or blend a gritty mix that drains freely.