I suggest that you "shell into" your docker image and take a look around. Figure out where your psql is installed and look at the value of your PATH environment variable. Here's the command to "shell into" your docker image:
docker run -it --entrypoint sh <image-name>
The image names are found in your docker environment with this command:
docker images
I know I had some trouble with python and psql (that I solved with a posting at SO). Here's the Dockerfile that I wound up with:
$ cat Dockerfile
FROM python:3.6-alpine as base
FROM base as builder
RUN mkdir /install
RUN apk update && apk add postgresql-dev gcc python3-dev musl-dev
WORKDIR /install
COPY requirements.txt /requirements.txt
RUN pip install --prefix=/install -r /requirements.txt
FROM base
COPY --from=builder /install /usr/local
ENV PATH="/app:${PATH}"
RUN apk --no-cache add libpq
COPY src /app
WORKDIR /app
ENTRYPOINT [ "myapp" ]
$ cat requirements.txt
click
requests
configparser
psycopg2
flask
I think that the only package you need from my requirements.txt file is psycopg2. Also, you'll clearly need to make some changes to include your dependencies and specify your entrypoint (rather than "myapp").
You may be able to completely ignore my entire posting and just focus on this aspect:
ENV PATH="/app:${PATH}"
The PATH tells the execution environment where to find your executables. The problem that you are seeing is that bash cannot find psql - so update your PATH to wherever psql is installed in your image. If you don't know the path to psql in your image, you might find it by run'ing your image (with the modified entrypoint as shown abouve) and just doing a find
from the root.
Or you can combine the commands as follows:
docker run -it --entrypoint sh <image-name> -c "find / -name psql "
Or you can even just make find
your entrypoint:
docker run -it --entrypoint find <image-name> / -name psql