Gardenias can thrive in containers with the proper care, so you do not have to plant it in the ground. I have included links to articles below that will help you diagnose the problems with your gardenia and restore it to good health.
Helping A Gardenia Bush With Yellow Leaves:
Gardenia Care To Get A Gardenia Bush To Bloom:
Gardenia Houseplants: Tips For Growing Gardenias Indoors