When you are in control of your feelings or impulses, that's called self-discipline. Even if it takes a lot of self-discipline not to giggle when your teacher solemnly scolds the class, you shouldn't let yourself do it.
Someone who has the trait of self-discipline is described as self-disciplined. It takes self-discipline to do all sorts of things, from practicing piano every day until you're ready for your recital, to resisting the urge to eat the cupcakes your brother baked for dessert, or biting your tongue instead of telling your cranky neighbor what you really think of her yappy dog. Discipline is used here to mean "practice, knowledge, or training," rather than "punishment."