Domesticated dogs do not fill a niche in wild ecosystems. However, wolves are the ancestors of modern domesticated dogs, and wolves fill the apex predator niche, eating rodents, rabbits, deer and other animals. When domestic dogs become feral, they often fill the niche of a scavenger.
Domestic dogs eat similar foods to their wild ancestors, which reflects their roots as an apex predator. According to PBS, gray wolves were domesticated approximately 130,000 years ago by primitive humans. Over thousands of years, humans selectively bred the wolves that had the traits that were desirable to humans. Those wolves' descendants are the domestic dogs alive today.