From 5fb22581bb1af47ff516e5fe291065e92416b5f8 Mon Sep 17 00:00:00 2001 From: Thomas Woerner <twoerner@redhat.com> Date: Tue, 27 May 2025 17:36:43 +0200 Subject: [PATCH] infra/image/shcontainer: Add host entry in container_start The management of hosts is deactivated in container_create to not copy all entries from the host system to the container. The host entry is now created in container_start to fix IPA deployment using this container. --- infra/image/shcontainer | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/infra/image/shcontainer b/infra/image/shcontainer index 3b6c4968..6e387cde 100644 --- a/infra/image/shcontainer +++ b/infra/image/shcontainer @@ -55,6 +55,17 @@ container_start() { log info "= Starting ${name} =" podman start "${name}" + # Add host entry to /etc/hosts + ip=$(podman inspect "${name}" --format "{{.NetworkSettings.IPAddress}}") + hostname=$(podman inspect "${name}" --format "{{.Config.Hostname}}") + if [ -n "${ip}" ] && [ -n "${hostname}" ]; then + cmd=$(cat <<EOF +sed -i -e "/[ \t]${hostname}/d" /etc/hosts +echo -e "$ip\t${hostname} ${hostname%%.*}" >> /etc/hosts +EOF + ) + podman exec "${name}" bash -c "$cmd" + fi # Ensure /etc/shadow is readable podman exec "${name}" bash -c "chmod u+r /etc/shadow" echo -- GitLab