Using the Chandra Source Catalog 2.0 and a newly compiled catalogue of galaxies in the local Universe, we deliver a census of ultraluminous X-ray source (ULX) populations in nearby galaxies. We find 629 ULX candidates in 309 galaxies with distance smaller than 40,Mpc. The foreground/background contamination is ${sim}20%$. The ULX populations in bona-fide star-forming galaxies scale on average with star-formation rate (SFR) and stellar mass ($M_star$) such that the number of ULXs per galaxy is $0.45^{+0.06}_{-0.09}timesfrac{rm SFR}{rm M_odot,yr^{-1}}{+}3.3^{+3.8}_{-3.2}timesfrac{M_star}{rm M_odot}$. The scaling depends strongly on the morphological type. This analysis shows that early spiral galaxies contain an additional population of ULXs that scales with $M_star$. We also confirm the strong anti-correlation of the ULX rate with the host galaxys metallicity. In the case of early-type galaxies we find that there is a non-linear dependence of the number of ULXs with $M_star$, which is interpreted as the result of star-formation history differences. Taking into account age and metallicity effects, we find that the predictions from X-ray binary population synthesis models are consistent with the observed ULX rates in early-type galaxies, as well as, spiral/irregular galaxies.