Role of electrostatic and magnetic electron confinement in a hollow-cathode glow discharge in a nonuniform magnetic field