Sakyamuni Buddha was a forest monk the the "forest tradition", following the sramana way of life, which involved abandoning conventional society and its religion.
Buddhist literature sometimes seem to present the Buddha as a domesticated monastery-dwelling monk, and the forest dwelling was his pre-Enlightenment struggles, but Reginald Ray in his book Buddhist Saints in India, says there the portrayal of Buddha in the earliest scriptures show the Buddha as a forest monk.
In the earliest Buddhism, the Buddha is clearly depicted as a forest renunciate who has attained enlightenment in the jungle. Others join him there as his disciples, and he teaches them the forest way of life.
Thus we read that Guatama initially determined to become a wanderer, living in the open air, begging his food, and practicing meditation. Meditating in the forest he encountered Mara, defeated him, and attained enlightenment. After his enlightenment, he continued to live a forest-lifestyle: the Suttanipatta says he wandered about, lived in the forest and dwelt alone, teaching the virtues of seclusion and solitude (viveka) to his disciples and being questioned by others on these virtues, Ray says.
"In fulfillment of his forest character, he dwells with no roof over his head and lives sometimes in specific forest locales, or upon particular mountains. In one verse, he is compared to a lion in a mountain cave. In his remote habitation, he does not abandon meditation, takes little food, and is restrained in speech."
"Moreover, abiding in the forest, he is available to teach the dharma to others. His supplicants, in order to see him and engage in his cult, know that he dwells in the forest and that they must go there to find him. On one occasion, King Bimbisara must climb Mount Pandava to see the Buddha."
"The dharma that the Buddha preaches to his renunciate disciples is, not surprisingly, one of forest renunciation, in which solitude and meditation are the essence and are not to be abandoned; and sleep is seen as an impediment [to meditation]."
Ray refers to the earliest strata of pali literature as contained in the Suttanipata, Dhammapada, Udana, Itivvttaka, Theragata, and Therigata.