It's not the fact of the interaction, per se, that creates mass. Let me see if I can clarify this. In relativity, when we speak of mass, we're usually talking about the invariant mass. This is what we would measure directly by putting an object on a scale, since it's rather hard to weigh anything that isn't sitting still. An object's invariant mass is given by the length of its 4-momentum vector:
[tex]m = \sqrt{p^\mu p_\mu} = \sqrt{E^2-|\vec{p}|^2},[/tex]
where I'm implicitly using units in which c = 1.
For a single photon or gluon, this will be 0. However, for a system of multiple particles, we have to sum the 4-momenta before squaring. Thus, the mass of a composite system looks like
[tex]m = \sqrt{\left(\sum_i E_i\right)^2-\left|\sum_i \vec{p}_i\right|^2}.[/tex]
Because of the vector sum of 3-momenta, a system of multiple massless particles can actually have a net non-zero rest mass.
This is where the interaction comes in. The nature of the strong force means that quarks and gluons only exist in bound states; and, the mass of the bound state must be determined as I showed above. If the bound state is at rest, the momentum sum will be 0; but, the energy sum will depend on the strength of the binding force, leading to a prediction for the mass of the bound state.
Does this clarify anything?