Pdeuxa
Pdeuxa

Reputation: 699

Docker, entrypoint strange behavior

I have the following Docker File (from ubuntu image):

...

WORKDIR ${DJANGO_BASE_DIR} //--> /opt/django

COPY --chown=${USERNAME}:${USERNAME} /deployment/entrypoint.sh ${DJANGO_BASE_DIR}

USER ${USERNAME}

RUN echo ${DJANGO_BASE_DIR} //--> /opt/django

CMD ["bash","entrypoint.sh"] // I also tried ENTRYPOINT

My entrypoint is the following:

...
echo "Waiting for postgres..."

while ! nc -z $DB_HOST $DB_PORT; do
  sleep 0.1
done
cd
echo "PostgreSQL started"
echo $DJANGO_DEBUG
echo $(pwd) // display /home/django
....

I don't understand why my entrypoint is running on /home/django directory; I expect it to run on the WORKDIR, which is /opt/django

Upvotes: 0

Views: 48

Answers (1)

timsmelik
timsmelik

Reputation: 742

The cd command in your entrypoint script sets the working directory to the current user's home directory. Remove that and it should work fine.

Upvotes: 3

Related Questions