It is very complex, but you raise a very good question.
The problem with getting a "booster" of immunity when you get a smaller dose of a virus from a person either carrying, or having an infection of a viral disease is mostly related to something called "infectious dose". The "infectious dose" is the minimum number of viruses you need to be exposed to in order to actually "catch" the disease. For the majority of viruses, it's not enough to get one, or even several hundreds of viruses in your body. When only a bunch of viruses enter your body, you body’s innate immune system can easily deal with them before they spread and cause the actual disease.
The problem is, the innate immune system does not create immunity for the future. So yes, you do boost your immunity every time you're exposed to a pathogen, but you may only be boosting your innate immunity (it still helps you to keep healthier in general, but won't give you specific protection against a specific virus).
In order to create immunity to any disease, your adaptive immune system needs to be involved and activated. This only happens when the number of viruses (or bacteria) inside your body is large enough to be noticed by your adaptive immune system, or when your innate immune system has not managed to contain the viruses.
Vaccines take advantage of this, by introducing a lot of either dead, inactivated or parts of a virus in your body, so your adaptive immune system is activated. But as the viruses are not able to produce the infection/disease, your body does not have to fight with the disease while creating immunity.
So getting exposed to a small amount of varicella zoster viruses may well not make any difference in your immunity to chickenpox, or to shingles.
For the majority of viruses, you need to get over 100,000 units of virus in order to actually get sick. There are exceptions, like for example noroviruses, which can cause disease just with a viral dose of some dozens of viruses (that's why they are so contagious and easy to catch).
This is just one of the many examples in which understanding the difference between a virus (or bacteria) and the disease it causes is essential in order to understand how it works.