  We develop Tannaka duality theory for dg categories. To any dg functor from a
dg category $\mathcal{A}$ to finite-dimensional complexes, we associate a dg
coalgebra $C$ via a Hochschild homology construction. When the dg functor is
faithful, this gives a quasi-equivalence between the derived dg categories of
$\mathcal{A}$-modules and of $C$-comodules. When $\mathcal{A}$ is Morita
fibrant (i.e. an idempotent-complete pre-triangulated category), it is thus
quasi-equivalent to the derived dg category of compact $C$-comodules. We give
several applications for motivic Galois groups.
