Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Wrapper examples fail when the script is created with default permissions

Đã đóng Phù hợp với người mới
#26,447 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@maheshrijal đang làm issue này rồi.

Từ ngày 26/10/2026.

  • #26448 của @maheshrijal — đang mở

Đánh giá

Độ khó
1/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
86/100
Loại issue
Tài liệu
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
docker, markdown
Lĩnh vực
documentation

Hướng nghiên cứu

Mở trang tài liệu về container đa dịch vụ và tìm cả hai ví dụ Dockerfile có script wrapper, sử dụng COPY và CMD ./my_wrapper_script.sh. Kiểm tra cách xử lý quyền của script trong từng ví dụ; bản tái hiện của issue cho thấy chế độ mặc định thất bại với trạng thái thoát 126, còn COPY --chmod=755 thì thành công. Hoàn tất khi cả hai ví dụ đều đặt script wrapper thành có thể thực thi hoặc nói rõ với người đọc rằng cần đặt quyền thực thi cho script trước khi build.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Markdown
Star
4.7k
Fork
8.5k
Merge trung bình
1 ngày 22 giờ
Pull request đã merge (30 ngày)
148

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của docker/docs

Tất cả issue của docker/docs

Issue tương tự

Thêm issue về Documentation

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.