Yes, this is true and the "proof" is as follows (I wouldn't really dare to call that a proof, though).
For any $u\in X$ write $f=-\Delta u$, and observe that trivially $u$ solves the elliptic PDE
$$
\left\{
\begin{array}{ll}
-\Delta u=f & \mbox{in }B\\
u=0 & \mbox{on }\partial B
\end{array}
\right..
$$
(This is a tautology, if you will.)
By standard elliptic regularity (see e.g. Evans' textbook on PDEs, section 6.3.2 and in particular remark (i) just after theorem 4) we get that
$$
\|u\|_{H^2(B)}\leq C \|f\|_{L^2(B)}=C \|\Delta u\|_{L^2(B)}\leq C
$$
for some purely dimensional $C\equiv C(n)$.
In other words, your set $X$ is bounded in $H^2$. The precompactness then follows from the Rellich-Kondrachov theorem applied to $u_i=\partial_{x_i}u$, with of course $\|\nabla u_i\|_{L^2}\leq \|u\|_{H^2}$ (the full Hessian of $u$ controls any first derivative of $u_i$).
For a more "serious" reference (by that I mean not a textbook) I can recommend Gilbarg-Trudinger.