MY old JRT, Russell, had a garbage habit when I got him.
I set him up. Left the lid open with something tempting inside (not that the lid ever stopped him, but I wanted to make my correction easy) and stepped around the corner. When he jumped up to knock it over, I came in behind him, stuffed him in the garbage can, shut the lid, and rolled it across the kitchen floor a few times. (not unlike the old time deer breaking method). And that was the end of his dumpster diving.