Let \(U_k(\mathbb {C})\) be the unitary associative algebra of \(k\times k\) upper triangular matrices with entries from the field \(\mathbb {C}\) of complex numbers, and \(F_k=F(U_k(\mathbb {C}))\) be the free algebra of rank 2 generated by the set \(\{u,v\}\) in the variety generated by \(U_k(\mathbb {C})\) . The algebra \(F_k\) satisfies the polynomial identity \([x_{1},x_{2}]\cdots [x_{2k-1},x_{2k}]=0\) . The dihedral group \(D_{2n}=\langle \rho ,\tau \mid \rho ^n=\tau ^2=(\tau \rho )^2=1\rangle \) acts on \(F_k\) as \(\rho (u)=e^{\frac{2\pi i}{n}}u\) , \(\rho (v)=e^{-{\frac{2\pi i}{n}}}v\) , \(\tau (u)=v\) , \(\tau (v)=u\) . In this study, we provide a generating set for the algebra \(F_k^{D_{2n}}\) of invariants of \(D_{2n}\) . We also compute the Hilbert series \(H(F_k^{D_{2n}},t)\) of \(F_k^{D_{2n}}\) for \(k=3,4\) .