This commit is contained in:
Wang Sen Di
2025-11-25 16:46:02 +08:00
parent b2ef31946b
commit e20ded8c11

View File

@@ -9,11 +9,11 @@ _latter="${_script_path_this#/apps/data}"
if [[ "$CONTAINER_NAME" == "" ]]; then CONTAINER_NAME=$(grep devices </proc/self/cgroup | grep -Po '[0-9a-z]{64}' | cut -c1-12); fi
if [[ "${APPS_DATA}" == "" ]]; then APPS_DATA=$(docker inspect "$CONTAINER_NAME" -f '{{range .Mounts}}{{if eq .Destination "/apps/data"}}{{.Source}}{{end}}{{end}}'); fi
if [[ "${APPS_DATA}" == "" ]]; then
# echo "nsenter.sh 未挂载 /apps/data 到外部路径"
_data_upper_dir=$(docker inspect "$CONTAINER_NAME" -f '{{.GraphDriver.Data.UpperDir}}')
_absolute_path="${_data_upper_dir}$_script_path_this"
# echo "nsenter.sh 未挂载 /apps/data 到外部路径"
_data_upper_dir=$(docker inspect "$CONTAINER_NAME" -f '{{.GraphDriver.Data.UpperDir}}')
_absolute_path="${_data_upper_dir}$_script_path_this"
else
_absolute_path="${APPS_DATA}$_latter"
_absolute_path="${APPS_DATA}$_latter"
fi
nsenter --mount=/host/proc/1/ns/mnt --net=/host/proc/1/ns/net /usr/bin/bash "$_absolute_path"