dockerd: build failed
Package Name
dockerd
Maintainer
@G-M0N3Y-2503
OpenWrt Version
25.12
OpenWrt Target/Subtarget
x86_64
Steps to Reproduce
build dockerd
Actual Behaviour
error log:
Building static bundles/binary-daemon/dockerd (linux/amd64)...
Created binary: bundles/binary-daemon/dockerd
Copying nested executables into bundles/binary-daemon
cp: cannot stat '': No such file or directory
make[3]: *** [Makefile:195: /home/ubuntu/openwrt/build_dir/target-x86_64_musl/dockerd-29.6.1/.built] Error 1
ERROR: package/feeds/packages/utils/dockerd failed to build.
Confirmation Checklist
- [x] The package is maintained in this repository.
- [x] I understand that issues related to the base OpenWrt repository or LuCI repository will be closed.
- [x] I am reporting an issue for OpenWrt, not an unsupported fork.
This PR https://github.com/openwrt/packages/pull/30288 fixed, but why closed?
Very good question. As for why it was closed, since you mentioned the link to the closed pull request, I think you can also find the relevant information there explaining what happened and why. In any case, as was mentioned there, more details need to be provided. Thanks for your cooperation.
I referenced https://github.com/openwrt/packages/pull/30288#issuecomment-5369613597, and after running "mv /usr/local/bin/runc /usr/local/bin/runc.bak" and then rebuilding, everything worked fine. It's clear that there's an issue in https://github.com/moby/moby/blob/b612274c5489b546ff8b4a4f93f25a0b8952713a/hack/make/binary-daemon#L13-L19, and this patch clearly resolves the issue effectively.
The issue clearly only occurs when "/usr/local/bin/runc" exists and is executable, because the subsequent "command -v" fails to find those files that OpenWrt doesn't actually need, causing the error.
Since that PR was closed, is there a better way to solve this issue?
I think you incorrectly closed a PR that correctly fixes this error. As @G-M0N3Y-2503 said in https://github.com/openwrt/packages/pull/30288#issuecomment-5369938235, this is the way to solve it. Also, I looked at the history of binary-daemon, and it's clearly a file that gets updated very infrequently (the last change was 4 months ago), so the so-called maintenance cost is almost nonexistent.
For some reason beyond me these programs should be in the PATH, I'm guessing the go build system promotes the built binaries to the PATH. However, the package depends on runc so this shouldn't be a problem if that's the case. So the best questions is why is it a problem? The question that PR answers is how can we avoid that question with the least collateral.
Your understanding is incorrect. It is clear that "binary-daemon" is attempting to copy these files from the system PATH (like "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"). For instance, containerd is a standalone file unrelated to the dockerd package and cannot possibly be generated when compiling dockerd.
Ref https://github.com/moby/moby/blob/b985e2313a8676e18072b442911fc8f64f17d440/hack/make/binary-daemon#L7-L9 This also indicates that copying is only executed when the native OS/ARCH matches the OS/ARCH of the build target, meaning these are definitely not files generated by golang.
Due to flaws in the binary-daemon code, the author assumed that as long as "/usr/local/bin/runc" exists and is executable, those files ("containerd containerd-shim-runc-v2 ctr runc docker-init rootlesskit dockerd-rootless.sh dockerd-rootless-setuptool.sh") must also exist on the system. The code fails to account for the possibility that cp might throw an error if one or more of these files cannot be found.
I reproduced this separately, and what @Signout-123 described matches the code path.
The dockerd binary is built successfully. The failure happens afterward, when Moby's hack/make/binary-daemon script tries to copy additional executables from the build host into the output directory.
openwrt package dependencies such as containerd and runc are built for the target device. They do not make those commands available in the build host's $PATH.
The failure happens when the host and target architectures match, /usr/local/bin/runc exists, and at least one of the other executables expected by Moby is missing. The script receives an empty path from command -v and passes it to cp.
I opened an upstream Moby issue:
https://github.com/moby/moby/issues/53442
While this is being handled upstream, I think a small downstream patch could still be useful (what do maintainers think?) . It could verify that all the expected executables are available before starting the optional copy step. If the set is incomplete, the script could skip that step with a useful message.
the patch could be removed after we get a new fix from upstream.
Just use https://github.com/openwrt/packages/pull/30288 directly. These copied files aren't needed by OpenWrt anyway. Once upstream updates then remove the patch.
@BKPepe @G-M0N3Y-2503 So, before this error is fixed upstream, could add a patch to fix it?
If there is a patch submitted upstream, it has been allowed before while it is in review, I'm not sure if that is still the case. I think the idea was that when it is merged or rejected it's removed from this repo. The patch would be referenced by a URL at that point though, not a file in this repo.