A method to control the diocotron instability of a hollow electron beam with periodic dipole magnetic fields has been investigated by a two-dimensional particle-in-cell simulation. At first, relations between the diocotron instability and several physical parameters such as the electron number density, the current and shape of the electron beam, and the solenoidal field strength are theoretically analyzed without periodic dipole magnetic fields. Then, we study the effects of the periodic dipole magnetic fields on the diocotron instability using the two-dimensional particle-in-cell simulation. In the simulation, we considered the periodic dipole magnetic field applied along the propagation direction of the beam, as a temporally varying magnetic field in the beam frame. A stabilizing effect is observed when the oscillating frequency of the dipole magnetic field is optimally chosen, which increases with the increasing amplitude of the dipole magnetic field.