The command below will return the corresponding strings
$ docker-compose exec postgres postgres --version
postgres (PostgreSQL) 10.4 (Debian 10.4-2.pgdg90+1)
I am trying to get the postgresql version but when I tried, the Debian version and other numbers are included like
$ pg_version=$(docker-compose exec postgres postgres --version | sed 's/[^0-9.]//g')
10.410.42.901
I am wondering how to get the 10.4
only