Anal glands or anal sacs are small glands found near the anus of most mammals. In dogs, they are often used to mark their territories and identify other dogs. When a dog deficates, the anal glands normally empty themselfs (when the feces is hard) to provide a lubricant for the anal opening. If the feces is too soft, the anal glands might not empty like they should. This can cause your dog some discomfort when the glands are full. You may notice your dog dragging its rear on the ground, licking/biting at the anus, tail chasing, and discomfort when sitting. In extreme cases, the gland can become impacted or even infected or abcessed. Veterinary care may be required to resolve this condition.
Normally, the anal glands empty themselves without a problem. This is most likely when your dog is on a healthy diet and maintains a healthy weight. Routine expressing of the anal glands when not needed is not recommended since it can disrupt the normal balance of a dog's excretion process, possibly increasing the risk of inflamation or infection. You should consult your veterinarian for a recommendation if this process is necessary for your dog.