gitlab 使用docker方式搭建

1. 简单使用docker run命令

docker run -d --net=bridge --restart=always --privileged=true --name=gitlab --hostname gitlab.crfchina.com --publish 1443:443 --publish 8080:80 --publish 2222:22  -e TZ='Asia/Shanghai' --volume /gitlab/config:/etc/gitlab  --volume /gitlab/logs:/var/log/gitlab --volume /gitlab/data:/var/opt/gitlab gitlab/gitlab-ce:10.6.4-ce.0

2. redis 和 postgresql外置

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:9.6-2

Step 2. Launch a redis container
docker run --name gitlab-redis -d \
    --volume /srv/docker/gitlab/redis:/var/lib/redis \
    sameersbn/redis:latest

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:9.5.2

3. docker-compose方式

wget https://raw.githubusercontent.com/sameersbn/docker-gitlab/master/docker-compose.yml



version: '2'
services:
  gitlab:
    image: 'gitlab/gitlab-ce:latest'
    container_name: my_gitlab
    restart: always
    hostname: '10.194.11.253'
    environment:
      TZ: 'Asia/Shanghai'
      GITLAB_OMNIBUS_CONFIG: |
        external_url 'http://10.194.11.253'
        gitlab_rails['time_zone'] = 'Asia/Shanghai'
        # gitlab_rails['smtp_enable'] = true
        # gitlab_rails['smtp_address'] = "smtp.exmail.qq.com"
        # gitlab_rails['smtp_port'] = 465
        # gitlab_rails['smtp_user_name'] = "[email protected]"
        # gitlab_rails['smtp_password'] = "password"
        # gitlab_rails['smtp_authentication'] = "login"
        # gitlab_rails['smtp_enable_starttls_auto'] = true
        # gitlab_rails['smtp_tls'] = true
        # gitlab_rails['gitlab_email_from'] = '[email protected]'
    ports:
      - '8080:80'
      - '2222:22'
    volumes:
      - /gitlab/config:/etc/gitlab
      - /gitlab/logs:/var/log/gitlab
      - /gitlab/data:/var/opt/gitlab

  redis:
    restart: always
    image: sameersbn/redis:latest
    command:
      - --loglevel warning
    volumes:
      - /gitlab/redis:/var/lib/redis:Z

  postgresql:
    restart: always
    image: sameersbn/postgresql:9.6-2
    volumes:
      - /gitlab/postgresql:/var/lib/postgresql:Z
    environment:
      - DB_USER=gitlab
      - DB_PASS=password
      - DB_NAME=gitlabhq_production
      - DB_EXTENSION=pg_trgm

or

version: '2'
services:
  gitlab:
    image: gitlab/gitlab-ce:10.6.4-ce.0
    container_name: gitlab
    privileged: true
    restart: always
    hostname: gitlab.crfchina.com
    environment:
      TZ: 'Asia/Shanghai'
      GITLAB_OMNIBUS_CONFIG: |
        external_url 'http://10.194.11.253'
        gitlab_rails['time_zone'] = 'Asia/Shanghai'
    ports:
      - '8080:80'
      - '2222:22'
      - '1443:443'
    volumes:
      - /gitlab/config:/etc/gitlab
      - /gitlab/logs:/var/log/gitlab
      - /gitlab/data:/var/opt/gitlab

你可能感兴趣的:(gitlab 使用docker方式搭建)