'psql:/home/git/gitlab/db/structure.sql:9: ERROR: permission denied to create extension "btree_gist"

I installed docker-gitlab from here

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' \
    --volume /srv/docker/gitlab/postgresql:/var/lib/postgresql \
    sameersbn/postgresql:12-20200524

Step 2. Launch a redis container

docker run --name gitlab-redis -d \
    --volume /srv/docker/gitlab/redis:/data \
    redis:6.2

Step 3. Launch the gitlab container

docker run --name gitlab -d \
    --link gitlab-postgresql:postgresql --link gitlab-redis:redisio \
    --publish 10022:22 --publish 10080:80 \
    --env 'GITLAB_PORT=10080' --env 'GITLAB_SSH_PORT=10022' \
    --env 'GITLAB_SECRETS_DB_KEY_BASE=long-and-random-alpha-numeric-string' \
    --env 'GITLAB_SECRETS_SECRET_KEY_BASE=long-and-random-alpha-numeric-string' \
    --env 'GITLAB_SECRETS_OTP_KEY_BASE=long-and-random-alpha-numeric-string' \
    --volume /srv/docker/gitlab/gitlab:/home/git/data \
    sameersbn/gitlab:14.8.0

But i got these errors from gitlab container:

database 'gitlabhq_production' already exists
2022-02-28T17:02:02.425099812Z psql:/home/git/gitlab/db/structure.sql:9: ERROR:  permission denied to create extension "btree_gist"
2022-02-28T17:02:02.425125024Z HINT:  Must be superuser to create this extension.
2022-02-28T17:02:02.426554719Z rake aborted!
2022-02-28T17:02:02.426575880Z failed to execute:
2022-02-28T17:02:02.426586706Z psql --set ON_ERROR_STOP=1 --quiet --no-psqlrc --file /home/git/gitlab/db/structure.sql --single-transaction gitlabhq_production
2022-02-28T17:02:02.426598928Z 
2022-02-28T17:02:02.426609892Z Please check the output above for any errors and make sure that `psql` is installed in your PATH and has proper permissions.


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source