方式1.官方Gitlab image啟動gitlab
sudo docker run --detach \ --hostname gitlab.example.com \ --publish 443:443 --publish 80:80 \ --name gitlab \ --restart always \ --volume /gitlab/config:/etc/gitlab \ --volume /gitlab/logs:/var/log/gitlab \ --volume /gitlab/data:/var/opt/gitlab \ gitlab/gitlab-ce:latest
進入容器
sudo docker exec -it gitlab /bin/bash
方式2.docker-compose啟動
version: '3.2' services: gitlab: image: gitlab/gitlab-ce:latest hostname: gitlab.example.com container_name: gitlab restart: always volumes: - /gitlab/config:/etc/gitlab - /gitlab/logs:/var/log/gitlab - /gitlab/data:/var/opt/gitlab ports: - 443:443 - 80:80 environment: GITLAB_OMNIBUS_CONFIG: | gitlab_rails['smtp_enable'] = true gitlab_rails['smtp_address'] = "smtp.gmail.com" gitlab_rails['smtp_port'] = 587 gitlab_rails['smtp_user_name'] = "[email protected]" gitlab_rails['smtp_password'] = "xxx" gitlab_rails['smtp_domain'] = "smtp.gmail.com" gitlab_rails['smtp_authentication'] = "login" gitlab_rails['smtp_enable_starttls_auto'] = true gitlab_rails['smtp_tls'] = false gitlab_rails['smtp_openssl_verify_mode'] = 'peer' networks: - devel-net logging: driver: "json-file" options: max-size: "10m" max-file: "3" networks: devel-net:
docker-compose up -d