Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 86 additions & 3 deletions docker/runtime/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,92 @@ Do not use `--pull` on a component build that consumes a locally built base.
- The runtime does not contain gdb, perf, BCC, iperf3, patchelf, vim, development
headers or Python 2. Use a separate diagnostic container when needed.
- FE images omit Arthas and its bundled dependencies.
- Both operator tools remain at `/opt/apache-doris/`. They are compiled from
the pinned doris-operator source with the updated Go toolchain, x/net and edwards25519;
Operator debug mode and compute-group discovery retain their commands.
- Both operator tools remain at `/opt/apache-doris/`. The runtime base builds
them from the pinned doris-operator source. For `dorisctl preflight`, use the
standalone CLI from the Operator release that matches the target CRDs and
controller.

## Running FE, BE and Meta Service without root

The standalone FE, BE and MS images run as `doris` (`10001:10001`) by default.
The MS image also runs Recycler under this identity. Build arguments
`DORIS_UID` and `DORIS_GID` accept unused decimal IDs in the base image
from 1 through 4294967294. The build scripts validate them before downloading
the archive. An omitted argument uses 10001. Image-owned configuration,
logs, metadata and storage directories are writable by this user. The SQL
administrator account is independent of the operating-system user. The image
provides `/etc/krb5.conf` as a link into the writable Doris configuration
directory, so Operator-mounted Kerberos configuration does not require writes
to `/etc` at startup.

Both `docker-build.sh` and `docker-build-ubi9.sh` forward `DORIS_UID` and `DORIS_GID` environment
variables to all three image builds. Use the same IDs in the image and the
Kubernetes configuration, and keep them stable across releases.

For Kubernetes, configure each component's Pod security context, for example:

```yaml
runAsNonRoot: true
runAsUser: 10001
runAsGroup: 10001
fsGroup: 10001
seccompProfile:
type: RuntimeDefault
```

Use the container security context to set `privileged: false`,
`allowPrivilegeEscalation: false` and drop all capabilities. With Doris Operator,
set BE `enableWorkloadGroup`
to `false` and `skipDefaultSystemInit` to `true` to avoid privileged cgroup
setup and the default system init container. Check the generated Pod to
confirm these settings; custom init containers must also be omitted.

With Operator 26.0.1, these settings are available without changing the
Operator. For a `DorisCluster`, set `feSpec.securityContext` and
`beSpec.securityContext`, and the corresponding `containerSecurityContext`
fields. For a `DorisDisaggregatedCluster`, configure `metaService`, `feSpec`
and every `computeGroups` entry. Set `skipDefaultSystemInit: true` and
`enableWorkloadGroup: false` on each BE/compute group when using Operator
26.0.1. With an Operator release that supports `systemInitMode`, prepare
the nodes and choose `NodePrepared` to retain the BE startup checks. The
Workload Group switch controls OS-level CPU setup. Query admission and
memory controls remain available.

The disaggregated FE and BE entrypoints copy their projected primary
configuration before applying cloud settings. FE preserves an explicitly
configured FQDN mode and defaults to enabling it when the projected file
omits it. On restart, the entrypoints replace their cloud assignments in
the writable working copy.

For MS, `doris_cloud.conf` from a ConfigMap is copied into a writable file
before applying `FDB_ENDPOINT`. Without that environment variable, the
configured `fdb_cluster` is preserved. The same entrypoint supports the
packaged default (Meta Service and Recycler) or explicit `--meta-service`
and `--recycler` arguments. FoundationDB and object storage are external
dependencies with their own container-user and storage requirements.

New volumes still need to be writable: image ownership does not override a
mounted volume's permissions. Validate the actual StorageClass with a fresh
PVC. A successful deployment with local-path storage is not proof that every
CSI driver supports the same permissions. The non-root configuration can be
validated in a namespace enforcing the Kubernetes `restricted` Pod Security
Standard; a storage provisioner's infrastructure is managed separately.

Skipping system initialization does not tune the host. Doris recommends
`vm.max_map_count >= 2000000`, disabled swap and a sufficient file-descriptor
limit. A non-root image cannot change these host settings. Operator versions
that set `SKIP_CHECK_ULIMIT=true` bypass startup checks, but this does not
remove the underlying kernel limits or their effects under load. Persistent
volumes must be writable by the configured UID/GID; `fsGroup` requires volume
driver support. Existing root-owned data needs its permissions prepared
separately. Custom log, cache, Kerberos and keytab paths must also be readable
or writable as required by Doris. A read-only container root filesystem is
not implied by running without root.

Without a writable, delegated CPU cgroup, Workload Group CPU weights and CPU
hard limits are unavailable. Leave `doris_cgroup_cpu_path` unset in this mode.
Other Workload Group controls, including query admission and memory limits,
remain available; Kubernetes container CPU limits continue to apply.

## MySQL TLS certificates

Expand Down
2 changes: 1 addition & 1 deletion docker/runtime/base-image/install-runtime-ubi9.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ microdnf "${repositories[@]}" update -y
microdnf "${repositories[@]}" install -y --setopt=install_weak_deps=0 \
bash ca-certificates curl-minimal findutils fontconfig gawk glibc-langpack-en \
grep gzip hostname iproute iputils jq libstdc++ mysql net-tools numactl \
openssl openssl-libs procps-ng sed tar tzdata util-linux wget which
openssl openssl-libs procps-ng sed shadow-utils tar tzdata util-linux wget which

# UBI Minimal keeps tzdata in the RPM database but removes its zoneinfo files.
# Installing an already-current RPM does not restore them; BE needs the files.
Expand Down
2 changes: 1 addition & 1 deletion docker/runtime/base-image/install-runtime.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ apt-get "${apt_options[@]}" upgrade -y --with-new-pkgs
# build-only packages so the same patch policy does not add unused tooling.
if [[ $# -eq 0 ]]; then
set -- curl fontconfig hostname iproute2 iputils-ping jq libstdc++6 \
"${mysql_client}" net-tools numactl openssl procps tzdata util-linux wget
"${mysql_client}" net-tools numactl openssl passwd procps tzdata util-linux wget
fi
# Accept the core-client name from either supported Ubuntu release so test
# images and explicit Jammy overrides use the same installer.
Expand Down
24 changes: 23 additions & 1 deletion docker/runtime/be/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,28 @@ FROM ${BASE_IMAGE}
ARG TARGETARCH

ARG DORIS_VERSION="x.x.x"
ARG DORIS_UID=10001
ARG DORIS_GID=10001

RUN for id in "${DORIS_UID}" "${DORIS_GID}"; do \
case "${id}" in ""|0*|*[!0-9]*) \
echo "DORIS_UID and DORIS_GID must be positive decimal IDs" >&2; exit 1 ;; \
esac; \
if [ "${#id}" -gt 10 ] || [ "${id}" -gt 4294967294 ]; then \
echo "DORIS_UID and DORIS_GID must not exceed 4294967294" >&2; exit 1; \
fi; \
done && \
groupadd --gid "${DORIS_GID}" doris && \
useradd --uid "${DORIS_UID}" --gid "${DORIS_GID}" --create-home --shell /bin/bash doris

ENV HOME=/home/doris


# set environment variables
ENV JAVA_HOME=/usr/lib/jvm/java
ENV PATH=$PATH:$JAVA_HOME/bin:/opt/apache-doris/be/bin

COPY resource/${TARGETARCH:-amd64}/apache-doris-${DORIS_VERSION}-bin-*/be /opt/apache-doris/be
COPY --chown=${DORIS_UID}:${DORIS_GID} resource/${TARGETARCH:-amd64}/apache-doris-${DORIS_VERSION}-bin-*/be /opt/apache-doris/be

COPY resource/be_*.sh /opt/apache-doris/

Expand All @@ -49,6 +64,13 @@ COPY resource/init_be.sh /usr/local/bin/

#RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

# Create writable runtime directories before dropping privileges.
RUN mkdir -p /opt/apache-doris/be/log /opt/apache-doris/be/storage && \
chown "${DORIS_UID}:${DORIS_GID}" /opt/apache-doris /opt/apache-doris/be/log /opt/apache-doris/be/storage && \
ln -sf /opt/apache-doris/be/conf/krb5.conf /etc/krb5.conf

USER ${DORIS_UID}:${DORIS_GID}

WORKDIR /opt/apache-doris

ENTRYPOINT ["bash","entry_point.sh"]
62 changes: 33 additions & 29 deletions docker/runtime/be/resource/be_disaggregated_entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,38 +94,32 @@ function add_cpu_limit_config()
fi
}

# update config add `deploy_mode`.
# Install the projected config before setting the cloud deployment mode.
update_conf_from_configmap()
{
echo "" >> $DORIS_HOME/conf/be.conf
echo "########## doris-operator automatically adds ##########" >> $DORIS_HOME/conf/be.conf
echo "deploy_mode = cloud" >> $DORIS_HOME/conf/be.conf
if [[ "x$CONFIGMAP_MOUNT_PATH" == "x" ]] ; then
log_stderr '[info] Empty $CONFIGMAP_MOUNT_PATH env var, skip it!'
return 0
if [[ -d "${CONFIGMAP_MOUNT_PATH:-}" ]]; then
local source target file
for source in "${CONFIGMAP_MOUNT_PATH}"/*; do
[[ -e "${source}" ]] || continue
file=${source##*/}
target="${DORIS_HOME}/conf/${file}"
if [[ -e "${target}" || -L "${target}" ]]; then
mv -fT -- "${target}" "${target}.bak" || return 1
fi
if [[ "${file}" == be.conf ]]; then
cp -- "${source}" "${target}" && chmod u+w "${target}" || return 1
else
ln -sfT -- "${source}" "${target}" || return 1
fi
done
fi
if ! test -d $CONFIGMAP_MOUNT_PATH ; then
log_stderr "[info] $CONFIGMAP_MOUNT_PATH not exist or not a directory, ignore ..."
return 0

local config="${DORIS_HOME}/conf/be.conf"
sed -i -E '/^[[:space:]]*deploy_mode[[:space:]]*=/d; /^########## doris-operator automatically adds ##########$/d' "${config}" || return 1
if [[ -n "$(tail -c 1 -- "${config}")" ]]; then
printf '\n' >> "${config}"
fi
local tgtconfdir=$DORIS_HOME/conf
for conffile in `ls $CONFIGMAP_MOUNT_PATH`
do
log_stderr "[info] Process conf file $conffile ..."
local tgt=$tgtconfdir/$conffile
if test -e $tgt ; then
# make a backup
mv -f $tgt ${tgt}.bak
fi
if [[ "$conffile" == "be.conf" ]]; then
cp $CONFIGMAP_MOUNT_PATH/$conffile $DORIS_HOME/conf/$conffile
echo "" >> $DORIS_HOME/conf/$conffile
echo "########## doris-operator automatically adds ##########" >> $DORIS_HOME/conf/$conffile
echo "deploy_mode = cloud" >> $DORIS_HOME/conf/$conffile
continue
fi
ln -sfT $CONFIGMAP_MOUNT_PATH/$conffile $tgt
done
printf '########## doris-operator automatically adds ##########\ndeploy_mode = cloud\n' >> "${config}"
}

# resolve password for root
Expand Down Expand Up @@ -549,6 +543,16 @@ mount_kerberos_config()
fi

KRB5_CONFIG_DIR=$(dirname "$KRB5_CONFIG")
# Resolve only the first link: the conf file may already link to a read-only ConfigMap.
if [[ -L "$KRB5_CONFIG" ]]; then
local config_link
config_link=$(readlink "$KRB5_CONFIG")
if [[ "$config_link" == /* ]]; then
KRB5_CONFIG_DIR=$(dirname "$config_link")
else
KRB5_CONFIG_DIR="$KRB5_CONFIG_DIR/$(dirname "$config_link")"
fi
fi
# If the krb5 directory does not exist, need to create it.
if [[ ! -d "$KRB5_CONFIG_DIR" ]]; then
log_stderr "[info] Creating krb5 directory: $KRB5_CONFIG_DIR"
Expand Down Expand Up @@ -624,7 +628,7 @@ else
log_stderr "[info] the host machine not support avx2 instruction set."
fi

update_conf_from_configmap
update_conf_from_configmap || exit 1
add_workloadgroup_config
add_cpu_limit_config
mount_kerberos_config
Expand Down
37 changes: 23 additions & 14 deletions docker/runtime/be/resource/be_entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -86,24 +86,23 @@ update_conf_from_configmap()
log_stderr '[info] Empty $CONFIGMAP_MOUNT_PATH env var, skip it!'
return 0
fi
if ! test -d $CONFIGMAP_MOUNT_PATH ; then
if [[ ! -d "${CONFIGMAP_MOUNT_PATH}" ]]; then
log_stderr "[info] $CONFIGMAP_MOUNT_PATH not exist or not a directory, ignore ..."
return 0
fi
local tgtconfdir=$DORIS_HOME/conf
for conffile in `ls $CONFIGMAP_MOUNT_PATH`
do
log_stderr "[info] Process conf file $conffile ..."
local tgt=$tgtconfdir/$conffile
if test -e $tgt ; then
# make a backup
mv -f $tgt ${tgt}.bak
local source target file
for source in "${CONFIGMAP_MOUNT_PATH}"/*; do
[[ -e "${source}" ]] || continue
file=${source##*/}
target="${DORIS_HOME}/conf/${file}"
if [[ -e "${target}" || -L "${target}" ]]; then
mv -fT -- "${target}" "${target}.bak" || return 1
fi
if [[ "$conffile" == "be.conf" ]]; then
cp $CONFIGMAP_MOUNT_PATH/$conffile $DORIS_HOME/conf/$file
continue
if [[ "${file}" == be.conf ]]; then
cp -- "${source}" "${target}" && chmod u+w "${target}" || return 1
else
ln -sfT -- "${source}" "${target}" || return 1
fi
ln -sfT $CONFIGMAP_MOUNT_PATH/$conffile $tgt
done
}

Expand All @@ -114,6 +113,16 @@ mount_kerberos_config()
fi

KRB5_CONFIG_DIR=$(dirname "$KRB5_CONFIG")
# Resolve only the first link: the conf file may already link to a read-only ConfigMap.
if [[ -L "$KRB5_CONFIG" ]]; then
local config_link
config_link=$(readlink "$KRB5_CONFIG")
if [[ "$config_link" == /* ]]; then
KRB5_CONFIG_DIR=$(dirname "$config_link")
else
KRB5_CONFIG_DIR="$KRB5_CONFIG_DIR/$(dirname "$config_link")"
fi
fi
# If the krb5 directory does not exist, need to create it.
if [[ ! -d "$KRB5_CONFIG_DIR" ]]; then
log_stderr "[info] Creating krb5 directory: $KRB5_CONFIG_DIR"
Expand Down Expand Up @@ -511,7 +520,7 @@ else
log_stderr "[info] the host machine not support avx2 instruction set."
fi

update_conf_from_configmap
update_conf_from_configmap || exit 1
add_workloadgroup_config
add_cpu_limit_config
mount_kerberos_config
Expand Down
13 changes: 12 additions & 1 deletion docker/runtime/build-runtime.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ if [[ ! "${version}" =~ ^[0-9]+\.[0-9]+\.[0-9]+([-._][a-zA-Z0-9._-]+)?$ ]]; then
exit 1
fi

DORIS_UID=${DORIS_UID-10001}
DORIS_GID=${DORIS_GID-10001}
for arg in DORIS_UID DORIS_GID; do
id=${!arg}
if [[ ! "${id}" =~ ^[1-9][0-9]{0,9}$ ]] || (( 10#${id} > 4294967294 )); then
echo "Invalid ${arg}: expected a decimal ID between 1 and 4294967294" >&2
exit 1
fi
done

runtime_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
work_dir=${DORIS_IMAGE_WORK_DIR:-"${runtime_dir}/../../output/runtime-images/${runtime_variant}"}
mkdir -p "${work_dir}"
Expand Down Expand Up @@ -75,7 +85,7 @@ fi
base_image=${DORIS_BASE_IMAGE:-"apache/doris:base-8.0-${runtime_variant}-jdk${java_version}"}
package_name="apache-doris-${version}-bin-${url_arch}"
archive_name="${package_name}.tar.gz"
download_base=${DORIS_DOWNLOAD_BASE_URL:-https://apache-doris-releases.oss-accelerate.aliyuncs.com}
download_base=${DORIS_DOWNLOAD_BASE_URL:-https://apache-doris-downloads.oss-accelerate.aliyuncs.com}
expected_sha512=${DORIS_ARCHIVE_SHA512:-}

# Read only the checksum, not paths or commands from the checksum document.
Expand Down Expand Up @@ -138,6 +148,7 @@ for role in fe be ms; do
image="${DORIS_IMAGE_PREFIX:-doris}.${role}:${version}${DORIS_IMAGE_TAG_SUFFIX-${runtime_tag_suffix}}"
docker build --no-cache --platform "linux/${arch}" \
--build-arg "BASE_IMAGE=${base_image}" --build-arg "JAVA_VERSION=${java_version}" \
--build-arg "DORIS_UID=${DORIS_UID}" --build-arg "DORIS_GID=${DORIS_GID}" \
--build-arg "DORIS_VERSION=${version}" -t "${image}" "${context}"
docker image inspect "${image}" > "${work_dir}/${role}-${version}-${arch}.image.json"
done
25 changes: 24 additions & 1 deletion docker/runtime/fe/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,27 @@ RUN rm -rf /artifacts/fe/arthas /artifacts/fe/mysql_ssl_default_certificate

FROM ${BASE_IMAGE} AS runtime

ARG DORIS_UID=10001
ARG DORIS_GID=10001

RUN for id in "${DORIS_UID}" "${DORIS_GID}"; do \
case "${id}" in ""|0*|*[!0-9]*) \
echo "DORIS_UID and DORIS_GID must be positive decimal IDs" >&2; exit 1 ;; \
esac; \
if [ "${#id}" -gt 10 ] || [ "${id}" -gt 4294967294 ]; then \
echo "DORIS_UID and DORIS_GID must not exceed 4294967294" >&2; exit 1; \
fi; \
done && \
groupadd --gid "${DORIS_GID}" doris && \
useradd --uid "${DORIS_UID}" --gid "${DORIS_GID}" --create-home --shell /bin/bash doris

ENV HOME=/home/doris

# set environment variables
ENV JAVA_HOME=/usr/lib/jvm/java
ENV PATH=$PATH:$JAVA_HOME/bin:/opt/apache-doris/fe/bin

COPY --from=artifacts /artifacts/fe /opt/apache-doris/fe
COPY --from=artifacts --chown=${DORIS_UID}:${DORIS_GID} /artifacts/fe /opt/apache-doris/fe

COPY resource/init_fe.sh /usr/local/bin/

Expand All @@ -53,6 +69,13 @@ COPY resource/fe_*.sh /opt/apache-doris/
# when you use beijing zone, please enable the set.
# RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

# Create writable runtime directories before dropping privileges.
RUN mkdir -p /opt/apache-doris/fe/log /opt/apache-doris/fe/doris-meta && \
chown "${DORIS_UID}:${DORIS_GID}" /opt/apache-doris /opt/apache-doris/fe/log /opt/apache-doris/fe/doris-meta && \
ln -sf /opt/apache-doris/fe/conf/krb5.conf /etc/krb5.conf

USER ${DORIS_UID}:${DORIS_GID}

WORKDIR /opt/apache-doris

ENTRYPOINT ["bash","init_fe.sh"]
Loading
Loading