user unbound variable on docker run
Asked Answered
R

1

7

While running docker image, I am receiving the following error:

/entrypoint.sh: line 7: USER: unbound variable 

Code of entrypoint.sh.

    #!/bin/bash
set -euo pipefail

export SPARK_DIST_CLASSPATH=$(hadoop classpath)
POSTGRES_TIMEOUT=60

echo "Running as: ${USER}"
if [ "${USER}" != "root" ]; then
  echo "Changing owner of files in ${AIRFLOW_HOME} to ${USER}"
  chown -R "${USER}" ${AIRFLOW_HOME}
fi

set +e

Declaration of Environment variable user in Docker File:

# Delay creation of user and group
ONBUILD ARG THEUSER=afpuser
ONBUILD ARG THEGROUP=hadoop

ONBUILD ENV USER ${THEUSER}
ONBUILD ENV GROUP ${THEGROUP}
ONBUILD RUN groupadd -r "${GROUP}" && useradd -rmg "${GROUP}" "${USER}"

Full code of Docker image is present in the Link

Respondent answered 8/6, 2017 at 7:38 Comment(4)
You should edit and write the basic part of your code that may be faulty, for example lines 1-7 from entrypoint.sh. That will be easier for people to answerEarthquake
@Earthquake Updated..Respondent
ONBUILD commands run, if your docker image is used as a base image for a derived build. You might need to add the same lines twice - once if ONBUILD, once without. (Not exactly sure what you want to achieve...)Chiropodist
If you end up here because of a similar issue in bitnami/postgresql chart, see this thread instead. It could be due to a dollar sign $ in the password. /entrypoint.sh: line 17: $4: unbound variable github.com/bitnami/bitnami-docker-postgresql/issues/213Hereinafter
I
0
  1. Remove spaces around the equal sign (=) in your .env file. Environment variable assignments should not have spaces before or after the equal sign.

  2. Make sure there are no extra spaces or special characters in the variable names or values. Double-check for any typos or incorrect characters in the variable names and values.

Hope this works for you.

Icebound answered 12/4, 2023 at 6:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.