Let me first note that there is a slight ambiguity when one says "ramified only at 2". Strictly speaking, that means that the extension is unramified at every place
of $\mathbb Q$ except 2, including infinity. The latter mean that the extension is totally real. Often, however, "ramified only at 2" means "ramified only possibly at 2 and $\infty$", and it is probably what you mean. Here, to remove
ambiguity, for $S$ a finite set of places of $\mathbb Q$, I will use "ramified only at $S$" in the strict sense.

That being said, the short answer is that whatever the finite set $S$, there are strong restrictions on the finite groups $G$ that can appear as the Galois group of an extension of $\mathbb Q$ unramified outside at $S$, but that in general, to "describe" all these restrictions (we may mean different things by that) is in general an open problem. To see what kind of restrictions can appear,
let us consider several situation, from the very particular to the general.

If $S=\emptyset$ or $S=\{\infty\}$, then Minkowski's theorem tell that there is no nontrivial extension unramified outside $S$, so the only possible Galois group $G$ is the trivial one. A very strong restriction indeed.

If $S$ is any set, but you try to determine what **abelian** $G$ may appear, then the answer is given by class field theory. Precisely, if $S=\{\ell_1,\dots,\ell_k,\infty\}$, then the abelian group which appear are the ones that are quotient of $\mathbb Z_{ell_1}^\ast \times \dots \mathbb Z_{\ell_k}^\ast$, and it is obvious that many abelian groups are not of this type (e.g. $\mathbb Z/\ell \mathbb Z$ for $\ell > \ell_1,\dots,\ell_k$). If $S=\{\ell_1,\dots,\ell_k\}$, replace $\mathbb Z_{ell_1}^\ast \times \dots \mathbb Z_{\ell_k}^\ast$ by its quotient by the diagonal subgroup $\{1,-1\}$.

If $S$ is any set, and you're interested in groups $G$ that are $p$-groups (for a $p$ that may or may nor be in $S$), then again, class field theory can help you
because of Frattini's argument saying that a $p$-group is generated by any set that maps subjectively to the maximal abelian $p$-torsion quotient of $G$.
So by the above, the $p$-groups $G$ appearing this way have a system of generators with less elements than the dimension over $\mathbb F_p$ of the maximal $p$-torsion quotient of $\mathbb Z_{ell_1}^\ast \times \dots \mathbb Z_{\ell_k}^\ast$. Is that all? No. We can describe in some cases all the $p$-group $G$ appearing, but not in all. For instance, with $S=\{2,\infty\}$, and $p=2$, the groups $G$ appearing are exactly the $2$-groups having a system of two generators, one of them being of square 1. For $S=\{2\}$, the only $2$-groups appearing are the cyclic groups. In general, the case $p \in S$ is better understood than the case $p \not \in S$. In the latter case, it is a folklore conjecture, on which not much is known, that only finitely many $p$-groups $G$ appearing (one can check readily that the conjecture is true for abelian $p$-groups, by the above paragraph).

If now we consider general finite groups $G$, well, the above shows that there are restrictions, but determining them all is largely open. For instance, a conjecture of Shafarevich states that there is an $n=n(S)$ such that every group $G$ which is the Galois group of an extension unramified outside $S$ has a system of generators with less than $n$ elements. But this is open in every non-trivial case.

Let me also mention a simple but too little known result of Serre, even if it is not strictly speaking part of your question: [Edit: Sorry, I messed up the statement of the result. Here is the right version]. If every finite group is a Galois group over $\mathbb Q$ (if the inverse galois problem has a positive solution) then every finite group is the Galois group of an extension of $\mathbb Q$ unramified at infinity -- that is, a real extension. In other words, according to the inverse Galois problem, there should need no restriction of $G$ in the case where $S$ is the set containing all finite places, but not the place at infinity.

Corps de nombres peu ramifiés et formes automorphes autoduales, Journal of the A.M.S. 22 Vol 2, 467-519 (2009) math.polytechnique.fr/~chenevier/articles/galoisQautodual2.pdf $\endgroup$ – YCor Sep 24 '14 at 13:25