Postgres relative path docker volume

Take the following Dockerfile in ~/foo

FROM postgres:10.4-alpine

LABEL description="This is the Curri Database built atop postgres."

ENV POSTGRES_USER=postgres
ENV POSTGRES_PASSWORD=hiiiiiiiiiii
ENV POSTGRES_DB=hola

VOLUME /var/lib/postgresql/data

EXPOSE 5432

To persist postgres data by using ~/foo/postgres-data as the data volume, run your docker container like so:

docker run -itd --volume=/$(pwd)/postgres-data:/var/lib/postgresql/data --name curri_db curri_db

The $(pwd) is the most important part, as docker run does not allow for relative paths like docker compose.