Can you define a greatest common divisor in a commutative ring that is not a domain? In a domain $R$ (commutatitive ring that has no zero divisors except $0$) the greatest common divisior of two elements $a,b\in R$ is a set of the form $dR^\times$ where $R^\times$ is the set of units of $R$ and $d\in R$ satisfies the following conditions:
(1) $d\mid a\land d\mid b$
(2) $\forall d'\in R:(d'\mid a\land d'\mid b\Rightarrow d'\mid d)$
Does the same definition also work if there are zero divisiors and what things about the GCD are still true or not true anymore?
Edit: To explain further what I mean: What general properties does a GCD have in the domain case (note that we don't assume a GCD domain, so a GCD might not always exist) and which of these properties are or are not also true in the general ring case?
Edit: To add an even more specific question: The ring of $p$-adic integers is a principal ideal domain and thus a GCD domain if $p$ is a prime. What happens if $p$ is not a prime? Does a GCD always exist?
 A: The definition can fail to work, in the sense that the set of all $d$ satisfying (1) and (2) may not have the form $dR^\times$.  For instance, let $R=\mathbb{Z}[x]/(5x)$, $a=x$, and $b=2x$.  Notice that $b=2a$ and $a=3b$, so $a\mid b$ and $b\mid a$.  It follows that $d=a$ and $d=b$ both satisfy conditions (1) and (2), and so should be elements of $\gcd(a,b)$.  But there is no unit $u$ such that $b=au$ (it is not hard to prove that $\pm1$ are the only units in $R$).
However, the case of $n$-adic integers when $n$ is not prime is quite easy and everything works well.  The reason is that if $p_1,\dots,p_m$ are the distinct prime factors of $n$, there is an isomorphism $$\mathbb{Z}_n\cong \mathbb{Z}_{p_1}\times\mathbb{Z}_{p_2}\times\dots\times\mathbb{Z}_{p_m}$$ (this is just a souped-up version of the Chinese remainder theorem).  It follows that all questions of divisibility in $\mathbb{Z}_n$ can be answered by handling each coordinate of this product separately.  So to find the GCD of two elements of $\mathbb{Z}_n$, you just find the GCDs of their components in each $\mathbb{Z}_{p_i}$.  Similarly, an element of $\mathbb{Z}_n$ is a unit iff each of its components is a unit, so it follows that any two GCDs of a pair of elements differ by a unit factor (since this is true in each $\mathbb{Z}_{p_i}$).
