Generally, no.
Knocking happens from pre-detonation, that's usually caused by heat from compression causing the fuel/air mix to ignite before it's triggered by spark.
To avoid this engines will run a fuel/air mix that is not stoicheometrically ideal, to make the mixture less likely to ignite early.
It is safer to run a fuel rich mix than to run a fuel lean mix as it keeps combustion chamber pressures low (unburned fuel takes heat out of the exhaust). It is more economical and more ecologically friendly to run fuel lean since you paid for that unburned fuel and it's kinda gross.
In general, more fuel than ideal means more resistance to knock. But these things are complex.
EDIT: Knocking happens from pre-detonation. Knocking can also happen from predestination, like in the case of turbocharged Subarus.