We're developing an app running in a Docker container: on-premises, so this question is purely about Amazon Linux 2 and has nothing to do with AWS.
I'm migrating the image from the one based on centos:7
to amazoncorretto:17
, based on amazonlinux:2
. Surprisingly, hostname -f
, which is used to get an FQDN inside a container, is failing because Amazon Linux 2 doesn't have hostname
.
We do need the host FQDN, and it gets propagated to containers either via host networking or via Docker's Swarm --hostname {{.Node.Hostname}}
, etc.
I have two questions:
- How do I get an FQDN without
hostname
?
- Why did Amazon Linux 2 remove it? Even Alpine has it. Would it make sense to put it back?
Yes, this seems to be the easiest fix.