I have a cat who can open every cabinet door in the house and who has taught the other cats to open doors and drawers.. and HE showed 'em how to get in the garbage.. I have no children but have to child proof all the doors and drawers in my house to be cat proof.
If I forget to latch and cat proof the kitchen I come home to a house with the trash strewn and the doors all open.. stuff out of the cabinets.. It truly looks "Cat"burglarized!" And, it has been.
Dogs are scavengers. They will eat where opportunity allows them to eat (sometimes to their detriment). To end this behavior you need to remove the opportunity by either being present OR by relocating the trash OR making the trash inaccessible some other way.
The dog will not stop the behavior. He has initiated something and been INSTANTLY rewarded with food. He has LEARNED by himself the same way we train!
I have a GSD too, but she is far too refined to get into the garbage... (Just kidding.. she never has had the opportunity).