Repository navigation
Replies: 1 comment 2 replies
|
Thank you for bringing this to my attention. The analysis was accurate in that the helper compared a 17-byte ASCII string. This resulted in inspect's 6-byte That length check was leftover from when #2420 corrects this by comparing |
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Hello — reporting this in Discussions rather than as a bug issue, because the bug form
requires confirming that I re-pulled
latestand reproduced against it, and I can't tickthat truthfully. Details of exactly what I did and didn't test are at the bottom. Please
move this to an issue if you'd like it tracked.
Disclosure up front: I troubleshooted this and wrote this report with AI assistance. The
diagnosis was reached by experiment on my own server and by reading your source — the logs
and endpoint dumps below are real output from real runs, not generated examples — but I want
you to know how it was produced so you can weigh it accordingly. Every claim here is
checkable against the source without my environment, and I've tried to be explicit about
where the evidence stops.
What I think is wrong
PR #2106 (released in v1.21.0) fixed #2104 by clearing engine-generated MACs on container
recreation. The code is present in the binary but I don't believe it can ever execute,
because of its guard:
dockerNetwork.HardwareAddrisgithub.com/moby/moby/api/types/network.HardwareAddr, whichis a byte slice, not a string:
So a MAC decoded from the Docker API is 6 bytes, never 17.
len(mac) != 17is always true,the function always returns
false, and the clearing branch inprocessEndpointisunreachable. The comparison has the same issue:
string(mac)is 6 raw bytes and can neverequal a 17-character
"02:42:.."string.The tests appear to pass because they build the value from a 17-character string literal —
dockerNetwork.HardwareAddr("02:42:ac:11:00:02")— which is a shape that doesn't occur whenthe value is decoded from the API. The test added in PR #2106 ("should clear engine-generated
MAC for running container") asserts on that hand-built value, so I don't think it exercises
the real path.
onlyGeneratedMacscalls the same helper, so it would be affected the same way.Suggested fix
HardwareAddrimplementsfmt.Stringer, which fixes both halves:A regression test that builds the endpoint by unmarshalling API-shaped JSON (or via
net.ParseMAC) rather than from a string literal would catch a recurrence.What I observed
I ran watchtower against a container whose MAC (
02:42:ac:21:00:02) exactly matches theengine-generated pattern for its IP (
172.33.0.2), made stale so it would be recreated.The container was recreated, and the MAC was carried into the new create config rather than
cleared.
Cleared engine-generated MAC addressnever appeared:Endpoint state before and after — the container is new, the MAC is unchanged, and it is now
a configured MAC rather than a generated one:
DesiredMacAddress(in/var/lib/docker/containers/<id>/config.v2.json) is populated onlyfor user-configured MACs — I confirmed that separately: a container started with a generated
MAC leaves it empty even across a restart, and
--mac-addresspopulates it. So it's areliable way to tell a frozen MAC from a healthy one, which plain
docker inspectcan't dowhen the frozen MAC happens to match the container's current IP.
If it's useful, the recipe is: put a container on a bridge network with
--mac-addresssetto the engine pattern for the IP it will get, make its image stale, then run
--run-once --no-pull --log-level debugagainst it. One gotcha that cost me a confusingrun: if your test container inherits
com.centurylinklabs.watchtower.enable=falsefrom itsimage's labels, watchtower silently scans nothing — override it with
--label com.centurylinklabs.watchtower.enable=true.Why this may not reproduce for you
As you noted on #2104, this isn't reproducible on recent Docker. I think the reason is that
moby switched the bridge driver from IP-derived to random MACs:
v27.5.1still callsGenerateMACFromIP,v28.0.0is the first to callGenerateRandomMAC(), and on currentmaster
GenerateMACFromIPis no longer referenced by the bridge driver at all. So theboundary looks like Docker 28.0.0 rather than 29.x — which may be worth correcting in
isEngineGeneratedMAC's doc comment, since it currently says "Docker 29.x+ switched thebridge driver to fully random MACs".
Anyone on Docker ≤ 27.x is still exposed. For context on why I'm not simply on a newer
Docker: 26.1.5 is what current Debian stable (13 / trixie) ships as
docker.io— it's thedistro default you get from
apt install docker.iotoday, not a stale or hand-pinnedinstall, and Debian stable isn't expected to move to 28.x within this release's lifetime.
So this isn't a niche configuration, and the affected population won't shrink on its own for
a while.
Why I'm reporting this
I'm not filing this theoretically — it's the root cause of a live problem on my server, and
I'd like to stop working around it.
Nextcloud All-in-One uses watchtower to update its mastercontainer and pins it by commit
(v1.21.2 in AIO v14.1.1, v1.22.1 on
main, with a v1.22.2 bump open). Because the fix neverfires, every AIO update re-freezes the mastercontainer's engine-generated MAC as a configured
one. On a later boot where that container doesn't get the same IP, a different container is
allocated the IP the frozen MAC encodes, and two containers end up sharing one MAC on the
bridge. AIO's UI health check is a 0.2 s TCP probe from the mastercontainer, which then times
out against the affected container — so containers sit on "Starting" forever while Docker
itself reports them healthy. Which container gets hit changes from boot to boot.
I've confirmed on my system that the mastercontainer's endpoint currently carries
DesiredMacAddressset, written by the current watchtower during the AIO 14.1.1 update.It's only benign right now because that container happens to hold the matching IP.
My workaround is to stop all containers in the AIO UI, reboot, then start them again, which
makes the mastercontainer claim the matching IP deterministically. It works, but it's a
manual dance around every reboot, and it has to be repeated because each AIO update
re-freezes the MAC.
What I tested, and what I didn't
Being explicit so you can judge how much weight to give this:
on Docker 26.1.5 (API 1.45), Debian 13.
nickfedor/watchtower:latest. I verified instead by reading thesource that
isEngineGeneratedMACis byte-identical at v1.21.2, at v1.22.2 (currentlatest) and on
main— samelen(mac) != 17guard atpkg/container/container_source.go:817-826. So I'm confident the defect is inlatest,but I haven't executed it there and won't claim otherwise.
to run more experiments on it, which is also why I'm not submitting via the bug form — its
checklist requires confirming a
latestre-pull and reproduction that I haven't done.AI help. The experiments were really run and the output is really from my machine, but I'd
rather you know that than discover it later.
Everything above is a single well-defined code path, so I'd hope the source inspection is
checkable in a couple of minutes without needing my environment. Happy to answer questions,
but I'd rather hand this over than keep poking at my own setup. Entirely your call how you
want to proceed.
All reactions