How did Dumbledore find Fawkes. Did Dumbledore have Fawkes even when working as a Transfiguration teacher or acquired it after having Headmaster position.

They both have a very strong bond between them. When did Dumbledore gain this.

Update: Dumbledore says that Ollivander wrote to him when Harry's wand was purchased; if Dumbledore did not have Fawkes before 1938, he would not know about the two feathers being in the wands, so Fawkes and Dumbledore must have met and bonded before 1938

“My wand's feather came from Fawkes?” Harry said, amazed.

"Yes,” said Dumbledore. “Mr. Ollivander wrote to tell me you had bought the second wand, the moment you left his shop four years ago.”

-Harry Potter and the Goblet Of Fire, Chapter 36-The Parting Of the Ways.

Update 2: JKR says that Dumbledore was the only owner of Fawkes. So it is to be believed that Fawkes was a wild Phoenix before its bonding with Dumbledore.

Peter Humphreys for BBC Newsround: Who did Fawkes previously belong to and will he play a vital role in the next book?

JK Rowling: I am not going to answer about the role in the next books, which probably gives you a big clue, and he has never been owned by anyone but Dumbledore. You will notice that when Harry goes back in the Pensieve in this book, Fawkes is never there, and ­­ no, I am sorry, not in this book, I take that back. When Harry has previously seen the study with a different headmaster he saw it with Dippet and Fawkes was not there then. Fawkes is Dumbledore's possession, not a Hogwarts possession.

The fact that Dumbledore knows Voldemort's wand contains one of Fawkes' feathers suggests they've been together at least since Voldemort was 11, but I don't think we know any more than that
– Jason BakerAug 9 '15 at 2:52

@JasonBaker Not even necessarily that—he could have found out later from Ollivander that Voldemort’s wand contained a Fawkes feather. Fawkes may have been with someone else when he gave the feather(s).
– Janus Bahs JacquetAug 9 '15 at 8:29

@JanusBahsJacquet No, Fawkes was not owned by anyone previous to Dumbledore, so he either already was in Dumbledores possession when he gave the feathers or by a crazy coincidence Dumbledore caught and domesticated the exact same wild Phoenix that Ollivander harvested feathers from.
– Lars EbertAug 11 '15 at 6:57

@LarsEbert So I realised by the quote that was edited in (after my comment, though).
– Janus Bahs JacquetAug 11 '15 at 6:58

As rand al-thor has pointed out, there is no clear canonical evidence explaining when Dumbledore tamed Fawkes or his methodology. In Fantastic Beasts and Where to Find Them: Volume 1 (2001), the august authority Newt Scamander merely states that they are immensely difficult to domesticate, without elaborating on why this may be.

Nevertheless, there are a couple of points that are suggestive of an answer to your question:

In The Chamber of Secrets, after Harry's rescue by Fawkes, Dumbledore explains that phoenixes are extremely loyal creatures, and "nothing but [real loyalty] could have called Fawkes to you".

From this we can glean that phoenixes value innocence and are attracted to loyalty. I submit that it is these two qualities, especially the latter, which Dumbledore possessed in spades, that drew Fawkes to him and encouraged him to stay with him until Dumbledore passed away.

Some examples: Dumbledore observed the universe with a sense of wonder and innocence, e.g. calling death "the next great adventure" (The Sorcerer's Stone), always looked for the best in people (The Deathly Hallows), gave people a second chance, such as Draco Malfoy, and was extremely loyal to those he trusted, most notably Snape. In fact, he stuck by Snape through thick and thin, was the only person who trusted him, and relied on his help, even though it ultimately caused his death! It was likely this deep rooted quality of loyalty that "called Fawkes" to him, sensing some sort of kindred spirit.

Sticking by Snape and relying on his help caused Dumbledore's death? Have you read Deathly Hallows?
– Rand al'Thor♦Aug 17 '15 at 20:52

Sure have; if D hadn't trusted S along with everyone else, S would've been shipped off to Azkhaban or been teaching potions on some rocky island off New Zealand, etc, and wouldn't have been at Hogwarts to kill D! Now of course, that doesn't mean D wouldn't have been offed in some other way during the course of the War, it just wouldn't have been at S's hands. & frankly, the whole elaborate 'plot' between D&S that HPDH was trying to weave that supposedly somehow necessitated D's death, I found extremely unconvincing, especially since D didn't even know about S's unbreakable vow!
– Meir IlluminationAug 18 '15 at 0:06

@MeirIllumination What makes you think Dumbledore didn't know about the Unbreakable Vow? The books heavily imply that he does. And what's unconvincing about it? Draco has been given the task of killing Dumbledore as a way of punishing his parents who have fallen from grace; if he fails, he will be killed—if he succeeds, he will be a murderer. The only way to avoid both is for someone else to kill Dumbledore (or suicide). Having Snape do it happens to also cement the Bad Guys’ trust in him and allows Dumbledore to go out on his own terms.
– Janus Bahs JacquetJan 21 '16 at 6:57

It's not known how Dumbledore came to own fawkes, but it does seem to suggest that he earned the birds trust by caring for it after each re-birth. As one would gain the trust of any bird by hand-rearing it.

I think Fawkes would have been drawn to Dumbledore due to the grief and guilt he felt over his role in Ariana's death. The phoenix lament helps with grief so I think he would entered his life in its aftermath.