Q: How can I access the postgres.conf of a postgres container on gitlab-ci? On Gitlab-CI I set up a postgres service for my database and would like to inspect the config file of it.
For this I let postgres return the location of the config file but when I go to that directory, it is empty. 
How can I access it?
.gitlab-ci.yaml:
image: maven:3.5.3-jdk-8

services:
  - postgres

variables:
  POSTGRES_DB: custom_db
  POSTGRES_USER: custom_user
  POSTGRES_PASSWORD: custom_pass

connect:
  image: postgres
  script:
  - export PGPASSWORD=$POSTGRES_PASSWORD
  - psql -h "postgres" -U "$POSTGRES_USER" -d "$POSTGRES_DB" -c "SELECT 'OK' AS status;"
  - psql -h "postgres" -U "$POSTGRES_USER" -d "$POSTGRES_DB"  -c "SHOW config_file;"
  - cd  /var/lib/postgresql/data
  - dir
  - ls -a
  - cat postgresql.conf

The respective job output:
Running with gitlab-runner 11.8.0 (4745a6f3)
  on docker-auto-scale 72989761
Using Docker executor with image postgres ...
Starting service postgres:latest ...
Pulling docker image postgres:latest ...
Using docker image sha256:30bf4f039abe0affe9fe4f07a13b00ea959299510626d650c719fb10c4f41470 for postgres:latest ...
Waiting for services to be up and running...
Pulling docker image postgres ...
Using docker image sha256:30bf4f039abe0affe9fe4f07a13b00ea959299510626d650c719fb10c4f41470 for postgres ...
Running on runner-72989761-project-7829066-concurrent-0 via runner-72989761-srm-1551974294-08e28deb...
Cloning repository...
Cloning into '/builds/kimtang/SpringBootTimeWithSwagger'...
Checking out 1399a232 as master...
Skipping Git submodules setup
$ export PGPASSWORD=$POSTGRES_PASSWORD
$ psql -h "postgres" -U "$POSTGRES_USER" -d "$POSTGRES_DB" -c "SELECT 'OK' AS status;"
 status 
--------
 OK
(1 row)

$ psql -h "postgres" -U "$POSTGRES_USER" -d "$POSTGRES_DB"  -c "SHOW config_file;"
               config_file                
------------------------------------------
 /var/lib/postgresql/data/postgresql.conf
(1 row)

$ cd  /var/lib/postgresql/data
$ dir
$ ls -a
.
..
$ cat postgresql.conf
cat: postgresql.conf: No such file or directory
ERROR: Job failed: exit code 1

Why does it state it is in /var/lib/postgresql/data but then can not be found?

A: You're connected to a remote docker instance via psql and you're checking a local directory. If you really want to check what's going on on the service docker image then ssh into the worker and then use the docker exec -i -t <container_name> /bin/sh command to log into the container. You will have to make the job run for a long time though so put some sleep in there.
