Your garbage is packed with things that a dog might find fascinating and, on occasion, delicious. Investigating the garbage becomes an immensely interesting and rewarding behavior, and so it is not the easiest habit to break. Trash strewn all over the kitchen floor or yard is unlikely to provide you with as much entertainment as it does him. You can try training techniques, but if that doesn’t work, try one of the several physical ways to keep garbage and the dog apart, which also work if the problem is other people’s dogs
Stop putting food scraps straight into the trash cans that your dog has access to. The smell of food just encourages him to investigate further, and finding it rewards the behavior. Instead, scrape all food scraps into a plastic bag and place it out of his reach. If the garbage won’t be collected for a while and you are anxious about the scraps rotting, put the bag in the freezer and only put it into the trash immediately before collection.
Supervise your dog whenever he is in the kitchen or yard. As soon as he makes a move towards the garbage, say “no” or “stop” firmly and make a distinctive loud noise, such as clapping your hands. Don’t leave him alone with the garbage at this stage.
Try one of the commercial garbage-training devices if you need to leave your dog alone with the trash or want to train him not to go in it at all. These basically are deterrents that do something startling, such as releasing a jet of compressed air, when your dog gets close enough to the trash to trigger them. The ASPCA notes that, although they are harmless, such devices are not appropriate if your dog suffers from anxiety.
Lock kitchen trashcans away, if possible, and place outdoor ones in a shed or garage if you can. If not, secure the lids. Animal-proof cans are available, which should stop even the biggest most determined dog, since they are designed to keep wild animals, including the wild relatives of dogs, out. For a stop-gap solution, tie the lids down with rope.