That's the idea behind Edward Jenner's smallpox vaccine, but only a few modern vaccines give live pathogens, or even neutralised pathogens as vaccines.
The COVID RNA vaccines (e.g. Pfizer/Moderna) contained messenger RNA that gave instructions to your body to construct proteins found on the surface of the COVID virus (specifically the spike proteins). Your immune system would then train itself on them.
You're not getting a small dose of virus, or even any parts of the virus, dead or alive. You're getting instructions on how to make a substance that the virus also contains. It's very impressive tech, but I do worry that it could be given blanket approval post-covid. The RNA instructions are just a delivery mechanism. What matters, from a safety point of view, is what the instructions tell the body to make.