Aims. We aim to quantify the relation between the dust-to-gas mass ratio (DTG) and gas-phase metallicity of z = 2.1 − 2.5 luminous galaxies and contrast this high-redshift relation against analogous constraints at z = 0. Methods. We present a sample of ten star-forming main-sequence galaxies in the redshift range 2.1 < z < 2.5 with rest-optical emission-line information available from the MOSDEF survey and with ALMA 1.2 millimetre and CO J = 3 − 2 follow-up observations. The galaxies have stellar masses ranging from 1010.3 to 1010.6 M⊙ and cover a range in star-formation rate from 35 to 145 M⊙ yr−1. We calculated the gas-phase oxygen abundance of these galaxies from rest-optical nebular emission lines (8.4 < 12 + log(O/H) < 8.8, corresponding to 0.5−1.25 Z⊙). We estimated the dust and H2 masses of the galaxies (using a metallicity-dependent CO-to-H2 conversion factor) from the 1.2 mm and CO J = 3 − 2 observations, respectively, from which we estimated a DTG. Results. We find that the galaxies in this sample follow the trends already observed between CO line luminosity and dust-continuum luminosity from z = 0 to z = 3, extending such trends to fainter galaxies at 2.1 < z < 2.5 than observed to date. We find no second-order metallicity dependence in the CO – dust-continuum luminosity relation for the galaxies presented in this work. The DTGs of main-sequence galaxies at 2.1 < z < 2.5 are consistent with an increase in the DTG with gas-phase metallicity. The metallicity dependence of the DTG is driven by the metallicity dependence of the CO-to-H2 conversion factor. Galaxies at z = 2.1 − 2.5 are furthermore consistent with the DTG-metallicity relation found at z = 0 (i.e. with no significant evolution), providing relevant constraints for galaxy formation models. These results furthermore imply that the metallicity of galaxies should be taken into account when estimating cold-gas masses from dust-continuum emission, which is especially relevant when studying metal-poor low-mass or high-redshift galaxies.