Maybe you need to wait for PostgreSQL service to be up and running.

Can you add a 10 seconds delay before trying the psql stuff? Something like:

 - sleep 10

If it works, then you can use a more specific solution to wait for PostgreSQL to be initialized, like Docker wait for postgresql to be running

Answer from emi on Stack Overflow
🌐
GitHub
github.com › sameersbn › docker-gitlab › blob › master › docker-compose.yml
docker-gitlab/docker-compose.yml at master · sameersbn/docker-gitlab
- postgresql · ports: - "10080:80" - "10022:22" volumes: - gitlab-data:/home/git/data:Z · healthcheck: test: ["CMD", "/usr/local/sbin/healthcheck"] interval: 5m · timeout: 10s · retries: 3 · start_period: 5m ·
Author   sameersbn
🌐
ComputingForGeeks
computingforgeeks.com › home › run gitlab ce in docker with docker compose
Run GitLab in Docker Containers using Docker Compose [Guide]
1 week ago - Apply configuration changes (after ... in the compose file and recreating the container, or after modifying /etc/gitlab/gitlab.rb inside the container). ... Open a Rails console for advanced troubleshooting (reset passwords, modify settings, etc.). sudo docker exec gitlab gitlab-rake gitlab:env:info · Display the full environment (GitLab version, Ruby, PostgreSQL, Redis versions, ...
Discussions

postgresql - problem with postgres docker container inside Gitlab CI - Stack Overflow
It's been few days I am blocked ... like to build a test database on the postgres docker image in gitlabCI but it doesn't work, I have try a lot of things and lose a lot of hours before ask this there :'(. below my docker-compose.yml file :... More on stackoverflow.com
🌐 stackoverflow.com
postgresql - PGHOST for GitLab pipeline with docker:dind for postgres created by docker-compose - Stack Overflow
I have a docker-compose file, that initializes postgres and service for postgres migration. And I want to run tests in gitlab pipeline against my docker-compose baked postgres service, but I can't More on stackoverflow.com
🌐 stackoverflow.com
How to Access Postgres Service from Child Docker Container in Gitlab-CI?
The issue relates to accessing a docker container from within a child docker-compose process running in docker:dind instance. I am using a gitlab CI docker executor build with the following architecture. The official gitlab-ci documentation recommends configuring a postgres instance as a service ... More on forums.docker.com
🌐 forums.docker.com
0
0
December 22, 2018
GitLab setup using official PostgreSQL and GitLab docker container not working - Stack Overflow
I am trying to setup GitLab using separate docker containers for both GitLab and PostgreSQL. I am using RancherOS v1.0.3 with Kubernetes enabled. For now, all i want is to have a single node having... More on stackoverflow.com
🌐 stackoverflow.com
🌐
GitLab
docs.gitlab.com › ee › ci › services › postgres.html
Using PostgreSQL | GitLab Docs
July 12, 2023 - variables: POSTGRES_DB: DB_name POSTGRES_USER: username POSTGRES_PASSWORD: password POSTGRES_HOST_AUTH_METHOD: trust · You can use any other Docker image available on Docker Hub.
🌐
Ralph's Open Source Blog
ralph.blog.imixs.com › 2019 › 06 › 09 › running-gitlab-on-docker
Running GitLab on Docker - Ralph's Open Source Blog
June 9, 2019 - This example can also be adapted to Docker Swarm. In the docker-compose file I split the Redis and PostgreSQL database into separate containers. There for you need to deactivate the internal databases. All configuration settings can be done in the environment variable named ‘GITLAB_OMNIBUS_CONFIG.
🌐
GitHub
github.com › mgcrea › docker-compose-gitlab-ce › blob › master › docker-compose.yml
docker-compose-gitlab-ce/docker-compose.yml at master · mgcrea/docker-compose-gitlab-ce
- ./volumes/runner:/etc/gitlab-runner · - /var/run/docker.sock:/var/run/docker.sock:rw · · postgres: image: postgres:${POSTGRES_VERSION} restart: always · container_name: gitlab_postgresql · # https://github.com/docker-library/docs/tree/master/postgres#environment-variables ·
Author   mgcrea
🌐
Docker Community
forums.docker.com › general
How to Access Postgres Service from Child Docker Container in Gitlab-CI? - General - Docker Community Forums
December 22, 2018 - Hi, Hopefully posting this in the correct forum. The issue relates to accessing a docker container from within a child docker-compose process running in docker:dind instance. I am using a gitlab CI docker executor build with the following architecture. The official gitlab-ci documentation recommends configuring a postgres instance as a service in .gitlab-cy.yml.
Find elsewhere
🌐
Webbureaucrat
webbureaucrat.dev › articles › running-and-connecting-to-postgres-using-docker-compose
Running and Connecting to Postgres Using Docker Compose
June 15, 2023 - Now we're ready to get started with our docker compose file. There's no magic here--we're just exposing our ports, referencing our database.env file, and feeding in our scripts from our scripts directory. ... version: "3.8" services: database: env_file: "database.env" image: postgres:latest ports: - "5432:5432" volumes: - ./database/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d
🌐
GitHub
github.com › sameersbn › docker-gitlab
GitHub - sameersbn/docker-gitlab: Dockerized GitLab
Alternatively, you can manually launch the gitlab container and the supporting postgresql and redis containers by following this three step guide. Step 1. Launch a postgresql container · docker run --name gitlab-postgresql -d \ --env 'DB_NAME=gitlabhq_production' \ --env 'DB_USER=gitlab' --env 'DB_PASS=password' \ --env 'DB_EXTENSION=pg_trgm,btree_gist' \ --volume /srv/docker/gitlab/postgresql:/var/lib/postgresql \ kkimurak/sameersbn-postgresql:16
Starred by 8.1K users
Forked by 2.2K users
Languages   Shell 91.0% | Ruby 5.0% | Dockerfile 2.8% | Makefile 1.2% | Shell 91.0% | Ruby 5.0% | Dockerfile 2.8% | Makefile 1.2%
🌐
TechOverflow
techoverflow.net › 2020 › 12 › 09 › how-to-run-psql-in-gitlab-docker-image
How to run psql in Gitlab Docker image | TechOverflow
January 2, 2026 - docker-compose exec -u gitlab-psql gitlab psql -h /var/opt/gitlab/postgresql/ -d gitlabhq_production
🌐
GitLab
forum.gitlab.com › gitlab ci/cd
How to Access Postgres Service from Child Docker Container? How do I access IP address of postgres service or gitlab shared runner? - GitLab CI/CD - GitLab Forum
December 22, 2018 - Hi, The documentation recommends configuring a postgres instance as a service in .gitlab-cy.yml. CI jobs defined in .gitlab-ci.yml, are able to connect to the postgres instance via the service name, ‘postgres’. I have …
🌐
GitLab
forum.gitlab.com › infrastructure as code & cloud native
Gitlab Docker-compose files - Infrastructure as Code & Cloud Native - GitLab Forum
April 29, 2016 - Not sure if this is useful to anyone, so I’ll just stick it here for comment. Gitlab publishes gitlab-ce and gitlab-ee Docker images on docker-hub; these are enormous, with postgresql, nginx, and redis included. I’ve cloned my example Gitlab deployment on Gitlab.
🌐
GitLab
forum.gitlab.com › how to use gitlab
Problems using docker-compose with gitlab-ci - How to Use GitLab - GitLab Forum
November 27, 2016 - Hi there, I'm just trying to wrap my head around Gitlab-CI and have some problems getting started. I've got a dockerized sample rails 5 app with a linked Postgres container (docker-compose). Locally this is working f…
🌐
Damagehead
damagehead.com › docker-gitlab
Docker GitLab by sameersbn
Step 1. Launch a postgresql container · docker run --name gitlab-postgresql -d \ --env 'DB_NAME=gitlabhq_production' \ --env 'DB_USER=gitlab' --env 'DB_PASS=password' \ --volume /srv/docker/gitlab/postgresql:/var/lib/postgresql \ sameersbn/postgresql:9.4-12
🌐
GitHub
github.com › mgcrea › docker-compose-gitlab-ce
GitHub - mgcrea/docker-compose-gitlab-ce: Compose file for Gitlab Community Edition · GitHub
git clone git@github.com:mgcrea/docker-compose-gitlab-ce.git gitlab; cd $_ cp .env.default .env; nano .env make docker-compose up -d · source .env docker run --rm -it gitlab/gitlab-ce:${GITLAB_CE_VERSION} postgres --version · gitlab.rb · Gitlab installation ·
Starred by 113 users
Forked by 42 users
Languages   Ruby 88.0% | Makefile 9.4% | Shell 2.6%
🌐
Docker Hub
hub.docker.com › r › sameersbn › gitlab-ci
sameersbn/gitlab-ci - Docker Image
Step 1. Launch a postgresql container · docker run --name gitlab-ci-postgresql -d \ --env 'DB_NAME=gitlab_ci_production' \ --env 'DB_USER=gitlab' --env 'DB_PASS=password' \ --volume /srv/docker/gitlab-ci/postgresql:/var/lib/postgresql \ sameersbn/postgresql:9.4-7 Copy
🌐
Self-Host Kutt With Docker
paulsblog.dev › how-to-deploy-gitlab-with-docker-in-5-seconds-or-less
How To Deploy GitLab With Docker In 5 Seconds Or Less
April 6, 2023 - Instead of downloading the up-to-date Compose file from Sameersbn, you can manually launch the GitLab container, a Redis container, and a PostgreSQL container with three simple steps. docker run --name gitlab-postgresql -d \ --env 'DB_NAME=gitlabhq_production' \ --env 'DB_USER=gitlab' --env 'DB_PASS=password' \ --env 'DB_EXTENSION=pg_trgm,btree_gist' \ --volume ./gitlab_postgresql:/var/lib/postgresql \ sameersbn/postgresql:12-20200524