Please see the below code snippet adapted from the Gitlab CI’s postgres service example project:
example: services: - postgres variables: # Configure postgres service (https://hub.docker.com/_/postgres/) POSTGRES_DB: custom_db POSTGRES_USER: custom_user POSTGRES_HOST_AUTH_METHOD: trust image: python script: # ... # Setup django application and do the migration # to the postgres database here ... # ... # The `postgres` service available makes # a postgres container available to this job. # How to use that postgres container # to run pg_dump here? - pg_dump ...
My usecase is as described in the comments above. I want to setup a django application, perform migration to the postgres database, then use
pg_dump to export that database as an artifact.
I have read and understand from the documentation that
The services feature ... does not, add any software from the defined services images to the job’s container..
I don’t want to add any software to the job container, I only want to use the software that is already present on the service container. For example, on my local machine, I can do the following:
docker run -it my-postgres-container-name pg_dump -U postgres ...
What is the equivalent approach to access the
postgres service container that is linked to the job?
Gitlab CI version: gitlab-runner 16.3.0 (8ec04662)