I am relatively new to docker. I have been trying to compose the file below:
version: "3"
services:
postgres:
restart: always
image: postgres
ports:
- "5432:5432"
environment:
- POSTGRES_DB=test_db
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD_FILE=/run/secrets/postgres-passwd
volumes:
- test_db:${PWD}
pgweb:
restart: always
image: sosedoff/pgweb
ports:
- "8081:8081"
environment:
- DATABASE_URL=postgres://postgres:POSTGRES_USER@POSTGRES_PASSWORD_FILE:5432/POSTGRES_DB?sslmode=disable
depends_on:
- postgres
volumes:
test_db:
What I am trying to do is mount the volume test_db to my current working directory by using the environment variable $PWD. When I run docker-compose up
in my terminal I get the following warning:
The PWD variable is not set. Defaulting to a blank string.
Now it is important to note that I am currently using Ubuntu running on WSL2 on windows 10. Another thing to note is that I am running ZSH and not BASH.
I followed the exact steps mentioned in the documentation.
I also checked another question which seemed to be similar to mine but not quite the same, as it was possible to replace ${PWD}
with ./
which simply does not work in my case.
When using ./
instead of $PWD
I get the following error:
for pg_test_postgres_1 Cannot create container for service postgres:\
invalid volume specification: 'pg_test_test_db:.:rw': invalid mount config\
for type "volume": invalid mount path: '.' mount path must be absolute