my aunt lived next to a guy who trained drug sniffing hounds for various branches of law enforcement. this was way out in the country, by lived next to i mean he was like a quarter mile away. anyways, i asked them about how dogs smell and he first stated that a well trained dog could smell a bag of cannabis inside a jar inside a metal oil drum (filled with oil) dropped into 20 feet of water. I think that was a bit of an exaggeration, but you get the idea. He also said that what makes them so good at smelling, is that their nose filters out information in a smiliar manner to how we do visually. When you are around a slice of pizza, you smell what you remember pizza smelling like. You see crust, cheese, sauce, pepperoni, green peppers, black widow spider eggs, all the typical toppings and such. You can get a good sense of where everything is located by looking at it, but you smell one big mass of food. A dog is the opposite, a dog just sees a triangle thing that it knows is pizza, but it can pick apart every single element in it with its nose and understand that the pizza is composed of many separate parts.
This is why dogs (and many other animals) are so adamant about sucking as much smell as they can from something they're interested in. A drug sniffing dog smells your jeans, the sweat from you in your jeans, hell it can smell the very dyes in your clothes, all the places you have been, the piece of gum stuck to your shoe, the soap that was on your hands that got transferred to your shoelaces when you tied them, the plastic bag holding ur shit, the grease from the AMERICAN-fries that were on your hands when you sealed the bag up... its conditioned to bark like a wild maniac the moment it smells what you have inside that bag.
Now he did tell me that the dog will only bark when its commanded to search for something specific. He said a cop just standing with a dog most likely wont bark at you if you have some contraband unless the cop orders it to sniff specifically for [weed...cocaine...etc]. I wouldn't risk that tho if I personally knew I was going to be in a situation where I would be confronted by a drug sniffing dog. Also drug sniffing dogs are not often trained as bomb sniffing dogs, and the other way around.
But basically, if a dog is commanded to sniff for something and you have it anyplace on you, and its trained well, you cant hide from it.