We investigate the energy spectrum and the corresponding eigenfunctions of a 2D Dirac oscillator confined by an antidot potential in the presence of a magnetic field and Aharonov-Bohm flux field. Analytical solutions are obtained and compared with the results of the Schrodinger equation found in the literature. Further, the dependence of the spectrum on the magnetic quantum number and on the repulsive potential is discussed.