For a generic two-dimensional 0A string background, we map the Dirac-Born-Infeld action to a matrix model. This is achieved using a canonical transformation. The action describes D0-branes in this background, while the matrix model has a potential which encodes all the information of the background geometry. We apply this formalism to specific backgrounds: For Rindler space, we obtain a matrix model with an upside-down quadratic potential, while for AdS_2 space, the potential is linear. Furthermore we analyze the black hole geometry with RR flux. In particular, we show that at the Hagedorn temperature, the resulting matrix model coincides with the one for the linear dilaton background. We interpret this result as a realization of the string...