rebuild_container emits empty TZ and HOST_HOSTNAME (var.ini never loaded)
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 253
- Forks
- 106
- Avg merge
- 6d 22h
- Merged PRs (30d)
- 12
Description
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
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with scripts/rebuild_container and compare its variable setup with scripts/update_container, then inspect xmlToCommand() in emhttp/plugins/dynamix.docker.manager/include/Helpers.php and the call from etc/rc.d/rc.docker. Reproduce with a minimal user template and inspect docker inspect output. Done means rebuilt containers receive the host’s TZ and HOST_HOSTNAME values from var.ini.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, php
- Domain
- devops
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 88/100