Wrapper examples fail when the script is created with default permissions
Maintainer thường phản hồi trong vòng 1 ngày
Đá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
- Có Dockerfile hoặc tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của docker/docs
-
[docs-scanner] Inconsistent terminology: 'nested organization' vs 'organization in the company'Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày
-
status/triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
docker/docs#26484 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[docs-scanner] SSO overview omits OAT as CLI authentication optionCó thể đã có người làm @dave123981 đã nhận 2 ngày trước. Đang mở
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 92/100
Maintainer thường phản hồi trong vòng 1 ngày
Issue tương tự
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 67/100
-
agent-butler-finding chore
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
jordansmall/spindrift#6158 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
priority:low type:docs
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
crazy-goat/rabbit-stream#958 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
documentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
alphagov/tech-docs-gem#580 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
content-freshness: staleOwnedContent doc comments still say 'complete receipt' (follow-up to #7912)Đang mởtriage:bug-verified
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 92/100
Maintainer thường phản hồi trong vòng 1 ngày