拆分gitlab ce版本以使用外部postgresql容器

时间:2019-04-18 14:31:56

标签: postgresql docker gitlab-ce

我们一直在使用docker来运行gitlab ce版本,因为它是从容器中出来的,一个容器运行着所有服务。

我们现在想将postgresql和redis容器移到它们自己的容器中。

我有点担心丢失主容器内postgresql服务器中当前的数据。

我先粘贴了当前的撰写文件,然后是建议的撰写文件。

有人可以确保我不会在此操作中刻录所有数据吗?

我想这是我在新的postgresql容器中有点担心的那一行

volumes:
  - /data03/containers/git/data/postgresql:/var/lib/postgresql:rw

当前撰写

version: "3.6"

services:  
  git:
    image: "gitlab/gitlab-ce:11.4.0-ce.0"
    deploy:
      replicas: 1
    hostname: git
    ports:
      - "80:80"
      - "2222:22"
    volumes:
      - /data03/containers/git/config:/etc/gitlab
      - /data03/containers/git/logs:/var/log/gitlab
      - /data03/containers/git/data:/var/opt/gitlab
    networks:
      - tooling
    logging:
      driver: "json-file"
      options:
        max-size: "50m"
        max-file: "1"

networks:
  tooling:
    external: true

建议新撰写

version: "3.6"

services:  
  git:
    image: "gitlab/gitlab-ce:11.4.0-ce.0"
    deploy:
      replicas: 1
    environment:
      GITLAB_OMNIBUS_CONFIG: |
        postgresql['enable'] = false
        gitlab_rails['db_username'] = "gitlab"
        gitlab_rails['db_password'] = "gitlab"
        gitlab_rails['db_host'] = "postgresql"
        gitlab_rails['db_port'] = "5432"
        gitlab_rails['db_database'] = "gitlabhq_production"
        gitlab_rails['db_adapter'] = 'postgresql'
        gitlab_rails['db_encoding'] = 'utf8'
        redis['enable'] = false
        gitlab_rails['redis_host'] = 'redis'
        gitlab_rails['redis_port'] = '6379'
    hostname: git
    ports:
      - "80:80"
      - "2222:22"
    volumes:
      - /data03/containers/git/config:/etc/gitlab
      - /data03/containers/git/logs:/var/log/gitlab
      - /data03/containers/git/data:/var/opt/gitlab
    networks:
      - tooling
    logging:
      driver: "json-file"
      options:
        max-size: "50m"
        max-file: "1"

  postgresql:
    deploy:
      replicas: 1
    image: postgres:9.6.2-alpine
    environment:
      - POSTGRES_USER=gitlab
      - POSTGRES_PASSWORD=gitlab
      - POSTGRES_DB=gitlabhq_production
    volumes:
      - /data03/containers/git/data/postgresql:/var/lib/postgresql:rw
    networks:
      - tooling
    logging:
      driver: "json-file"
      options:
        max-size: "50m"
        max-file: "1"


  redis:
    deploy:
      replicas: 1
    image: redis:3.0.7-alpine
    networks:
      - tooling
    logging:
      driver: "json-file"
      options:
        max-size: "50m"
        max-file: "1"

networks:
  tooling:
    external: true

0 个答案:

没有答案