As per Timatic, the database used by Airlines:
Passengers can obtain a transit visa at Dubai (DXB) for a maximum of 96 hours. The passenger must:
transit for at least 8 hours; and
have onward ticket to a third country; and
have a passport valid for a minimum of 6 months from the
E-visas can be obtained before departure at www.ednrd.ae .
Passengers must have a printed e-visa confirmation and airlines can check the validity of the e-visa on the same site by clicking on "Query GDRFA-D APP"
In other words, you can get a visa on arrival, or apply for an electronic entry permit HERE. The second option would invariably get you through immigration quicker, because you need nothing other than your passport, entry permit and possibly onward flight confirmation.