Get container’s IP address from the host

docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' container_name_or_id

source

Run postgres client using a docker container

# connect to an external database
docker run -it postgres:_tag_ psql -h _host_ -U _user_ -d _database_

# connect to a database in a container
docker run -it --network _some-network_ postgres:_tag_ psql -h _host_ -U _user_ -d _database_