Many people believe that milk jugs, glass or other empty containers can deter both dogs and cats from their lawn. The milk jugs are not filled with milk, of course: The milk would only attract dogs and cats as it spoiled. The jugs are instead filled with water, and possibly other substances, before being placed on the lawn.
Some believe that placing a jug of water on the lawn will keep dogs from defecating there. Dogs are believed to avoid messing up areas where there is a water source. There is no concrete data that supports the effectiveness of this practice, but a water source could continue to attract the dog to the lawn even if it doesn't defecate there.
Mixing some ammonia or mothballs with water in the plastic jug is believed to deter dogs. Dogs are evidently annoyed by the smell and will stay away from the lawn that is emanating that smell. There is no evidence to support the effectiveness of this practice, either. Though they should shy away from the solution, you should put a grid over it to keep animals from ingesting it.
Filling the plastic milk jug completely with water can reflect the image of any dog that gets close. This image will evidently deter some dogs from the area. However, many dogs will bark and become aggressive when they feel challenged or come into contact with another dog instead of running away from it. This may create more of a nuisance then it prevents.
Some place milk jugs full of water in and around their flower beds to deter cats. According to the City of Marion in South Australia, the light reflecting off the water in the jugs will deter cats. Some believe that cats are deterred by any water that is not for drinking.