Getting incoming mail to work when port forwarding from a router

Having had another go and realising I’d put the IP address/hostname the wrong way around in the /etc/hosts file I think I’ve got it working. However, if the mail-receiver container is restarted it loses the extra line I appended to the container’s /etc/hosts file. Is there a way to get the mail-receiver.yml file to add the extra line automatically?