containers / buildah

A tool that facilitates building OCI images.
https://buildah.io
Apache License 2.0
7.44k stars 784 forks source link

[bug] hostnames in /etc/hosts invalide/too long (postfix install fatal error on newaliases command) #3972

Closed Dexus closed 2 years ago

Dexus commented 2 years ago

Description

/kind/bug

I try to build a container with postfix in it, but it fails because the hostname is to long. This works on docker without problems.

Steps to reproduce the issue:

  1. build docker image from debian:11-slim and try to install postfix

Describe the results you received:

# Generated by Buildah
# Static table lookup for hostnames.
# See hosts(5) for details.
127.0.0.1   7d5e95253d45e47a60a8a1d07b410bd48327b6525df5a2575e48a2e7a6c33e77-working-container e5c4c84a4f82
::1         7d5e95253d45e47a60a8a1d07b410bd48327b6525df5a2575e48a2e7a6c33e77-working-container e5c4c84a4f82
192.168.178.33         host.containers.internal
Setting up postfix (3.5.6-1+b1) ...
Creating /etc/postfix/dynamicmaps.cf
setting myhostname: 7d5e95253d45e47a60a8a1d07b410bd48327b6525df5a2575e48a2e7a6c33e77-working-container
setting alias maps
setting alias database
changing /etc/mailname to mymail.example.com
setting myorigin
setting destinations: mymail.example.com, $myhostname, 7d5e95253d45e47a60a8a1d07b410bd48327b6525df5a2575e48a2e7a6c33e77-working-container, localhost.localdomain, localhost
setting relayhost: 
setting mynetworks: 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
setting mailbox_size_limit: 0
setting recipient_delimiter: +
setting inet_interfaces: all
setting inet_protocols: all
/etc/aliases does not exist, creating it.
WARNING: /etc/aliases exists, but does not have a root alias.

Postfix (main.cf) is now set up with a default configuration.  If you need to 
make changes, edit /etc/postfix/main.cf (and others) as needed.  To view 
Postfix configuration values, see postconf(1).

After modifying main.cf, be sure to run 'systemctl reload postfix'.

Running newaliases
newaliases: warning: valid_hostname: hostname label too long: 7d5e95253d45e47a60a8a1d07b410bd48327b6525df5a2575e48a2e7a6c33e77-working-container
newaliases: fatal: file /etc/postfix/main.cf: parameter myhostname: bad parameter value: 7d5e95253d45e47a60a8a1d07b410bd48327b6525df5a2575e48a2e7a6c33e77-working-container
dpkg: error processing package postfix (--configure):
 installed postfix package post-installation script subprocess returned error exit status 75
Processing triggers for rsyslog (8.2102.0-2) ...
invoke-rc.d: could not determine current runlevel
invoke-rc.d: policy-rc.d denied execution of try-restart.
Processing triggers for libc-bin (2.31-13+deb11u3) ...
Errors were encountered while processing:
 postfix
E: Sub-process /usr/bin/dpkg returned an error code (1)

Describe the results you expected:

An /etc/hosts entry that is valide and not too long (max 63 octets or less for label) and is valide to the RFC https://www.ietf.org/rfc/rfc1035.txt

Output of buildah version:

1.25.1

Current workaround: use --no-hosts and copy own /etc/hosts

flouthoc commented 2 years ago

Hi @Dexus Thanks for opening the issue but I think this is already resolved here: https://github.com/containers/buildah/issues/3892 I'm closing this issue but comment below if you think I was wrong.

Thanks