Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

Wrapper examples fail when the script is created with default permissions

Geschlossen Anfängerfreundlich
#26,447 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

@maheshrijal arbeitet bereits daran.

Seit 26.10.2026.

  • #26448 von @maheshrijal — offen
  • #26456 von @eknathdj — offen

Bewertung

Schwierigkeit
1/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
86/100
Issue-Typ
Dokumentation
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
docker, markdown
Bereich
documentation

Rechercherichtung

Öffne die Dokumentationsseite zu Multi-Service-Containern und suche beide Dockerfile-Beispiele mit Wrapper-Skript, die COPY und CMD ./my_wrapper_script.sh verwenden. Prüfe, wie in den beiden Beispielen die Skriptberechtigungen gehandhabt werden; die Reproduktion des Issues zeigt, dass der Standardmodus mit Exit-Status 126 fehlschlägt, während COPY --chmod=755 funktioniert. Die Aufgabe ist erledigt, wenn beide Beispiele das Wrapper-Skript ausführbar machen oder den Lesern klar sagen, dass sie vor dem Build die Ausführungsberechtigung setzen müssen.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

Is this a docs issue?
  • My issue is about the documentation content or website
Type of issue

Information is incorrect

Description

Both wrapper-script Dockerfiles copy my_wrapper_script.sh and run it with CMD ./my_wrapper_script.sh. A newly created script normally has mode 0644 under umask 022, and Docker COPY preserves that mode. The container then exits with status 126 because the wrapper cannot be executed. This happens before the wrapper's Bash code runs.

This minimal reproduction shows the failure, a Dockerfile COPY --chmod=755 control, and a host-executable-file control. It requires Docker Engine and access to pull ubuntu:latest.

set -eu
workdir=$(mktemp -d)
cd "$workdir"
umask 022
cat > my_wrapper_script.sh <<'EOF_SCRIPT'
#!/bin/bash
exit 0
EOF_SCRIPT
cat > Dockerfile <<'EOF_DOCKERFILE'
FROM ubuntu:latest
COPY my_wrapper_script.sh my_wrapper_script.sh
CMD ./my_wrapper_script.sh
EOF_DOCKERFILE

base_image="wrapper-mode-base-$$"
chmod_image="wrapper-mode-chmod-$$"
host_image="wrapper-mode-host-$$"
docker build --no-cache -t "$base_image" .
set +e
output=$(docker run --rm "$base_image" 2>&1)
status=$?
set -e
printf 'default-mode run exit: %s\n%s\n' "$status" "$output"
if [ "$status" -ne 126 ]; then
  echo "Expected exit 126; got $status" >&2
  exit 1
fi
if printf '%s\n' "$output" | grep -Fq 'Permission denied'; then
  :
else
  echo 'Expected a permission-denied error' >&2
  exit 1
fi

sed 's/^COPY my_wrapper_script/COPY --chmod=755 my_wrapper_script/' Dockerfile > Dockerfile.chmod
docker build --no-cache -f Dockerfile.chmod -t "$chmod_image" .
docker run --rm "$chmod_image"

chmod +x my_wrapper_script.sh
docker build --no-cache -t "$host_image" .
docker run --rm "$host_image"

The second, Bash job-control recipe has the same COPY and CMD instructions. It was also tested separately: the published Dockerfile fails before Bash starts, and adding only --chmod=755 lets the wrapper start and finish in a TTY run. The TTY matters because its fg command can race with a short-lived stand-in under non-TTY input.

Location

https://docs.docker.com/engine/containers/multi-service_container/

Suggestion

Add --chmod=755 to the wrapper COPY instruction in both Dockerfile examples, or state that readers must make the wrapper executable before building the image.

Vorherrschende Sprache
Markdown
Sterne
4.7k
Forks
8.5k
Ø Merge
1 T. 22 Std.
Gemergte PRs (30 T.)
151

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus docker/docs

Alle Issues in docker/docs

Ähnliche Issues

Weitere Issues zu Documentation

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.