Container can access hosts dns records but service task cant

I have added a few dns entires to my hosts /etc/hosts file.
If I start a container I can ping these dns entries (even though they are on my host, not the container itself) but if my container gets started by a service it can’t ping these dns records.

Is this the intended behaviour or am I missing something?