How to run Mattermost from a domain name instead of IP address?

Yes, please see “ServiceSettings” and “Port” as referenced here: Preview: Documenting config.json settings (pre-Mattermost v1.0)