主机dbeaver访问gitlab容器中的pg

映射5432端口- '5431:5432'或者从docker客户端查看

复制代码
version: '3.6'
services:
  web:
    image: 'gitlab/gitlab-ce:latest'
    restart: always
    hostname: 'localhost'
    environment:
      GITLAB_OMNIBUS_CONFIG: |
        external_url 'http://localhost:8929'
        gitlab_rails['gitlab_shell_ssh_port'] = 2224
    ports:
      - '8929:8929'
      - '2224:22'
      - '5431:5432'
    volumes:
      - '/Users/yanlp/workspace/docker/gitlab_latest/config:/etc/gitlab'
      - '/Users/yanlp/workspace/docker/gitlab_latest/logs:/var/log/gitlab'
      - '/Users/yanlp/workspace/docker/gitlab_latest/data:/var/opt/gitlab'
    shm_size: '256m'

登陆容器修改postgresql配置docker exec -it 28e24039b4b6 /bin/bash

  • 配置pg开启外部端口监听

    复制代码
    $ vi /var/opt/gitlab/postgresql/data/postgresql.conf;
    
    #listen_addresses = '' 修改为   
    listen_addresses = '*'    # what IP address(es) to listen on;
  • 配置pg白名单

    复制代码
    $ vi /var/opt/gitlab/postgresql/data/pg_hba.conf
    
    # TYPE  DATABASE    USER        CIDR-ADDRESS          METHOD
    
    # 最后一行追加
    # "local" is for Unix domain socket connections only
    local   all         all                               peer map=gitlab
    host    all         all         0.0.0.0/0             trust # 全部允许 最大权限配置
  • 重启pg并查看5432端口

    复制代码
    $ gitlab-ctl restart postgresql
    $ netstat -an | grep 5432
  • 查看pg绑定用户名more /etc/passwd

  • 查看gitlab database配置 more /opt/gitlab/embedded/service/gitlab-rails/config/database.yml或者more /var/opt/gitlab/gitlab-rails/etc/database.yml

  • 创建新用户并授权(可忽略)

    复制代码
    $ su - gitlab-psql
    $ psql -h /var/opt/gitlab/postgresql -d gitlabhq_production 
    
    CREATE USER gitlab_psql WITH PASSWORD 'test-admin';
    GRANT ALL PRIVILEGES ON DATABASE gitlabhq_production to gitlab_psql;
    GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO gitlab_psql;

主机dbeaver连接pg

相关推荐
jekc8682 天前
Ubuntu-GitLab
服务器·ubuntu·gitlab
在路上走着走着3 天前
openclaw v2026.4.5 版本 提示 pairing required 解决方案
gitlab
Gazer_S7 天前
【GitLab npm Registry 非标准端口安装问题解决方案】
前端·npm·gitlab
-KamMinG7 天前
Gitlab版本升级方案-13.x到17.x
gitlab
菜鸡00019 天前
把一个项目传到 GitLab 的某个群组
大数据·elasticsearch·gitlab
AlbertS10 天前
记一次推送lfs失败不能迁移git仓库到新的gitlab的问题
git·ai·gitlab·lfs·rejected
日更嵌入式的打工仔10 天前
Windows 下 GitLab 完整使用指南
windows·gitlab
会飞的大可10 天前
Jenkins vs GitLab CI/CD:2026 企业级 CI/CD 工具深度选型评测
ci/cd·gitlab·jenkins
庭風10 天前
让 AI 从需求直接走到 MR:我开源了一个面向 GitLab 的工作流 MCP
gitlab
Sakuyu4346811 天前
Git-GitLab-JenKins
git·gitlab·jenkins