A scanning Hall probe microscope is used to study flux pinning in a thin superconducting Pb film covering a square array of single-domain Co dots with in-plane magnetization. We show that single flux quanta of opposite sign thread the superconducting film below T(c) at the opposite poles of these dipoles. Depending on the polarity of the applied field, flux lines are attracted to a specific pole of the dipoles, due to the direct interaction with the vortexlike structures induced by the local stray field.