docker使用gitlab持续集成(1)
修改ssh连接端口vi /etc/ssh/sshd_config
写docker-compose.yml文件配置gitlab
version: '3' services: gitlab: image: 'gitlab/gitlab-ce-zh:latest' restart: unless-stopped hostname: 'http:192.168.31.200' container_name: gitlab-zh:latest environment: TZ: 'Asia/Shanghai' GITLAB_OMNIBUS_CONFIG: | external_url 'http://192.168.31.200/' registry_external_url 'http://192.168.31.200' 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'] = "xxxx@xx.com" # 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'] = 'xxxx@xx.com' ports: - '80:80' - '443:443' - '22:22' volumes: - ./data:/var/opt/gitlab:Z - ./config:/etc/gitlab:Z - ./logs:/var/log/gitlab:Z
配置文件来自https://www.cnblogs.com/mmry/p/9000718.html的博文,稍有改动,比如最下面的3给 加上了 (:Z) 否则会提示权限不够
编写sh文件
sudo docker run --detach \ --hostname 192.168.31.200\ --name gitlab-runner \ --restart always \ --volume /var/run/docker.sock:/var/run/docker.sock \ --volume /srv/gitlab-runner/config:/etc/gitlab-runner:Z \ --volume /srv/gitlab-runner/logs:/var/log/gitlab-runner:Z \ --volume /srv/gitlab-runner/data:/var/opt/gitlab-runner:Z \ gitlab/gitlab-runner:latest
继续配置gitlab-runner
version: '3' services: runner: image: 'gitlab/gitlab-runner:latest' container_name: gitlab-runner restart: always volumes: - ./config:/etc/gitlab-runner - /var/run/docker.sock:/var/run/docker.sock:Z