Equilibrium measure for a nonlocal dislocation energy with physical confinement