We report a study of the thermal conductivity $kappa$ of the spin-ice material Dy$_2$Ti$_2$O$_7$. From the anisotropic magnetic-field dependence of kappa$ and by additional measurements on the phononic reference compounds Y$_2$Ti$_2$O$_7$ and DyYTi$_2$O$_7$, we are able to separate the phononic and the magnetic contributions to the total heat transport, i.e. $kappa_{ph}$ and $kappa_{mag}$, respectively, which both depend on the magnetic field. The field dependent $kappa_{ph}$ arises from lattice distortions due to magnetic-field induced torques on the non-collinear magnetic moments of the Dy ions. For $kappa_{mag}$, we observe a highly anisotropic magnetic-field dependence, which correlates with the corresponding magnetization data reflecting the different magnetic-field induced spin-ice ground states. The magnitude of $kappa_{mag}$ increases with the degree of the ground-state degeneracy. This anisotropic field dependence as well as various hysteresis effects suggest that $kappa_{mag}$ is essentially determined by the mobility of the magnetic monopole excitations in spin ice.