You can make dulce de leche by simply cooking ingredients in a pan on the stove top. Alton Brown has a good recipe. It only takes 1.5 to 2 hours, and you don't have to worry about a container. This recipe begins with regular whole milk. There are similar recipes available from other sources. These recipes add baking soda to increase the pH and speed up the Maillard reaction.
However, from your question, I suspect that you might be beginning with sweetened condensed milk. Serious Eats simply puts the can (without opening) into a pot of water, where it is simmered for 2 to 3 hours.
If you want to remove the contents and use a mason jar (as @FuzzyChef suggests), I would fill close to the top, allowing a little head space, and tighten "finger tip tight". Pressure will build up in the jar (or the can). But the proper use of mason jars is important so that you avoid cracking. "Finger tip tight" means to tighten the ring gently, that back off slightly. If you use the can, at least according to the Serious Eats recipe, you should have no issues.
By the way, the Serious Eats recipe that uses a can only takes 2 to 3 hours. Seven hours seems like a long time. I think your end product will be quite dark by then, but maybe that is your goal.