Skip to content

Replace uname -m with rpm --query for userspace arch detection#274

Merged
mmm-choi merged 1 commit intocorretto:mainfrom
mmm-choi:replace-uname-with-rpm-query
Apr 3, 2026
Merged

Replace uname -m with rpm --query for userspace arch detection#274
mmm-choi merged 1 commit intocorretto:mainfrom
mmm-choi:replace-uname-with-rpm-query

Conversation

@mmm-choi
Copy link
Copy Markdown
Contributor

@mmm-choi mmm-choi commented Apr 3, 2026

Summary

Replace $(uname -m) with rpm --query --queryformat='%{ARCH}' rpm in all AL2 and AL2023 Dockerfiles.

Motivation

Addresses feedback from @tianon on PR #21053:

  1. uname -m reports kernel architecture, which doesn't necessarily match the userspace architecture. Using rpm --query queries the actual userspace architecture, which is more correct for RPM-based images.

  2. Capture architecture in a variable before use — inline $(uname -m) subshells can swallow errors. Capturing ARCH early in the && chain ensures proper error propagation under set -eux.

Changes

  • Added ARCH="$(rpm --query --queryformat='%{ARCH}' rpm)" early in the RUN command chain (right after set -eux)
  • Replaced all $(uname -m) occurrences with ${ARCH}
  • 24 Dockerfiles modified across Corretto 8, 11, 17, 21, 25, 26 (all AL2 and AL2023 variants)

Not Modified

  • Alpine Dockerfiles (use apk add, no uname -m)
  • Debian Dockerfiles (use apt-get, no uname -m)
  • al2-generic Dockerfiles (use yum install from repo, no direct RPM downloads)
  • slim Dockerfiles (use package managers)

Testing

  • Built and verified java -version on AL2 (11/jdk/al2) and AL2023 (17/jdk/al2023, 8/jre/al2023) images
  • All container-structure-tests pass
  • Confirmed zero remaining uname -m in any AL2/AL2023 Dockerfile

Replace $(uname -m) with rpm --query --queryformat='%{ARCH}' rpm in all
AL2 and AL2023 Dockerfiles. This queries the actual userspace architecture
instead of the kernel architecture, which is more correct for RPM-based
images.

The architecture value is captured in an ARCH variable early in the RUN
command chain (after set -eux), ensuring proper error propagation. All
subsequent uses reference ${ARCH} instead of inline $(uname -m) subshells.

Addresses feedback from docker-library maintainer on PR #21053.

Files changed: 24 Dockerfiles across Corretto 8, 11, 17, 21, 25, 26
(all AL2 and AL2023 variants: jdk, jre, headful, headless)

Not modified: Alpine, Debian, al2-generic, and slim Dockerfiles
(these use package managers, not direct RPM downloads)
@mmm-choi mmm-choi merged commit 08df98d into corretto:main Apr 3, 2026
68 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants