Certified GKH Gardening Expert
It has grown leggy probably because it needs a brighter window or some light from a flourescent lamp. No reason it can't go in a pot. I like this article because it gives some details about how to grow the plant in a pot: https://www.gardeningknowhow.com/edible/fruits/avocado/indoor-avocado-plant-care.htm
Be sure to pay attention to the pot size recommendations. Too large and it can cause your plant to be overwatered.