Assume $D$ lies in $\mathbb{R}^2$ and define $f:D\rightarrow D$ by $f(x):=2x$ if $\|x\|\leq 1/2$ and $f(x):=\frac{x}{\|x\|}$ if $\|x\|\geq 1/2$. Then, $f$ is onto and continuous, but it is not injective. It is easy to see that $f^\ast :C(D)\rightarrow C(D)$ is an injective $^\ast$-homomorphism, but it is not onto.