Skip to content

rebuild_container emits empty TZ and HOST_HOSTNAME (var.ini never loaded) #2738

Description

@Vituhlos

Summary

scripts/rebuild_container creates containers with an empty TZ and empty
HOST_HOSTNAME
, because it never loads /var/local/emhttp/var.ini.

xmlToCommand() builds those two environment variables from $var:

$Variables[] = 'TZ="'.$var['timeZone'].'"';
$Variables[] = 'HOST_HOSTNAME="'.$var['NAME'].'"';

(emhttp/plugins/dynamix.docker.manager/include/Helpers.php, 7.3.0)

scripts/update_container populates $var before calling it:

$var = parse_ini_file('/var/local/emhttp/var.ini');

scripts/rebuild_container does not, and include/DockerClient.php does not
populate $var either — so global $var resolves to nothing and both
variables are emitted empty.

grep -c "var.ini" scripts/rebuild_container   # 0
grep -c "var.ini" scripts/update_container    # 1

Reproduction

Unraid 7.3.0. Host has NAME="Tower", timeZone="Europe/Budapest" in
/var/local/emhttp/var.ini.

Using a minimal user template (alpine, bridge, one port/path/variable):

scripts/rebuild_container <Name>
docker inspect <Name> --format '{{range .Config.Env}}{{println .}}{{end}}'

Result:

HOST_OS=Unraid
HOST_HOSTNAME=
HOST_CONTAINERNAME=<Name>
TZ=

The same template via scripts/update_container <Name> ca_docker_run_override:

TZ=Europe/Budapest
HOST_OS=Unraid
HOST_HOSTNAME=Tower
HOST_CONTAINERNAME=<Name>

Existing GUI-created containers on the same host all carry
TZ=Europe/Budapest and HOST_HOSTNAME=Tower, confirming the expected values.

Impact

rebuild_container is not only a manual tool — it is invoked by Unraid itself
from etc/rc.d/rc.docker during network restore:

if [[ -n ${REBUILD_CONTAINERS[$CONTAINER]} && ${PRIMARY_NETWORK[$CONTAINER]} == $NETWORK ]]; then
  log "rebuild container $CONTAINER"
  if OUT=$(/usr/local/emhttp/plugins/dynamix.docker.manager/scripts/rebuild_container "$CONTAINER" 2>&1); then

So a container rebuilt on that path silently loses its timezone. Anything
inside the container that depends on local time — log timestamps, cron-style
schedules, time-based application logic — shifts to UTC without any indication
to the user, and the container's own template still says nothing is wrong.

Suggested fix

Load var.ini in rebuild_container the way update_container already does,
before the first xmlToCommand() call.

Secondary observation

rebuild_container (and update_container) exit 0 even when the container
was not created
— for example when the image cannot be pulled. Progress and
errors go to the nchan channel via publish(), so nothing reaches stdout or
the exit status.

That makes the failure branch in rc.docker above unreachable in practice:
the if OUT=$(...) test succeeds regardless, so
log "failed to rebuild container ..." never fires and
REBUILD_CONTAINERS[$CONTAINER] is cleared even after a failed rebuild.

Happy to split that into its own issue if preferred.

Environment

  • Unraid 7.3.0, kernel 6.18.29, Docker 29.4.3
  • Source reviewed at tag 7.3.0

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions