Suppose $I$ is an ideal in a ring $R$ and $J,K$ are ideals such that $I\subseteq J\cup K$. Then either $I\subseteq J$ or $I\subseteq K$. Indeed, suppose that there is some $x\in I$ such that $x\not\in J$. If $y\in I$ is arbitrary and $y\not\in K$ then $x + y$ is in neither $J$ nor $K$. Thus, $y\in K$ and so $I\subseteq K$.
In other words, if there is some element of $I$ that is not in $J$, then $I$ is contained entirely in $K$.
A generalisation for commutative rings is as follows: if $J_1,J_2,\dots,J_n\subseteq R$ are ideals such that at most two of them are not prime ideals, and $I$ is an ideal such that $I\subseteq \cup_i J_i$ then $I\subseteq J_k$ for some $k$. Of course, one does not need the hypothesis that at most two of the $J_1,\dots,J_n$ are not prime if $I$ is principal.
If one drops the hypothesis that at most two of the ideals $J_1,\dots,J_n$ are not prime, then the conclusion no longer holds in general, though.
For example, consider the ring $R = \Z/2[x,y]/(x^2,y^2)$. It is a ring with sixteen elements. In $R$, the ideal $(x,y)$ has eight elements. Furthermore,
$$(x,y)\subseteq (x)\cup (y)\cup (x+y).$$
However, each of the ideals $(x), (y),$ and $(x+y)$—none of which are prime—only has four elements, and so $(x,y)$ is not contained in any of them.