Los Angeles increased its lead in the National League West to 10 1/2 games over Arizona.
Gonzalez produced his first blast in the third inning to give the Dodgers a 4-0 lead and his second homer came during a five-run seventh. A.J. Ellis added a solo shot in the seventh.
Ryu (13-5) allowed a lone run on eight hits with six strikeouts over 6 1/3 innings. He ended a personal two-game losing streak.
Eric Stults (8-12) was charged with the loss after allowing four runs on eight hits in 5 1/3.
2014: NFL Cheerleaders [PHOTOS]
Julius Randle breaks leg during NBA debut