[docker-in-docker] `docker-init.sh` prints `grep: /proc/modules: No such file or directory` on kernels without loadable-module support

Open Beginner friendly
#1,770 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 3 days

Nobody has claimed this yet.

Assessment

Difficulty
1/5
Estimated time
Under an hour
Newbie friendliness
88/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
docker, shell
Domain
devops

Research direction

The check is in src/docker-in-docker/install.sh; read the iptablesSwitchAtRuntime backend selection described in the issue. Reproduce on a kernel without loadable-module support and confirm startup prints the missing /proc/modules error. Done when that error is silenced and the fallback to iptables-nft still works.

Written by the indexing model from the issue text.

Description

With iptablesSwitchAtRuntime at its default of true, docker-init.sh prints an error on every start when the kernel is built without loadable-module support, because /proc/modules doesn't exist there.

The check is in src/docker-in-docker/install.sh:

if type iptables-legacy > /dev/null 2>&1 \
   && { grep -qE '^(ip_tables)\b' /proc/modules \
        || [ -d /sys/module/ip_tables ]; } \

grep -q doesn't suppress the error for a missing file, so the message goes to stderr:

grep: /proc/modules: No such file or directory

The backend selection still works: the grep fails, the /sys/module check runs next, and the script falls through to iptables-nft.
So this is only noise, but it looks like a failure to anyone reading container startup output.

Reproduction: feature version 4.1.3, in a microsandbox (msb 0.7.13) guest on kernel 6.12.113, built without loadable modules.
Any container or VM on such a kernel should behave the same.

Suggested fix: silence that one grep, leaving the rest of the logic as it is:

   && { grep -qE '^(ip_tables)\b' /proc/modules 2>/dev/null \

Related: #1709 concerns the same iptablesSwitchAtRuntime check.

Dominant language
Shell
Stars
1.6k
Forks
626
Avg merge
4d 10h
Merged PRs (30d)
7

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from devcontainers/features

All issues in devcontainers/features

Similar issues

More Shell/Bash issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.