用docker-compose搭建mysql,gitlab,nexus,harbor,jenkins

我的linux环境是ubuntu18.04

首先安装docker:apt install docker.io
然后配置加速器
安装docker-compose

curl -L https://github.com/docker/compose/releases/download/1.24.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose

mysql

version: '3.1'
services:
  db:
    image: mysql:8.0.20
    restart: always
    container_name: mysql
    environment:
      MYSQL_ROOT_PASSWORD: 123456
    command:
      --default-authentication-plugin=mysql_native_password
      --character-set-server=utf8mb4
      --collation-server=utf8mb4_general_ci
      --explicit_defaults_for_timestamp=true
      --lower_case_table_names=1
    ports:
      - 3306:3306
    volumes:
      - ./data:/var/lib/mysql

gitlab

下面的ip改成你自己虚拟机的IP地址

version: '3.1'
services:
    web:
      image: 'twang2218/gitlab-ce-zh:11.1.4'
      restart: always
      hostname: 'ip'
      container_name: 'gitlab'
      environment:
        TZ: 'Asia/Shanghai'
        GITLAB_OMNIBUS_CONFIG: |
          external_url 'http://ip'
          gitlab_rails['gitlab_shell_ssh_port'] = 2222
          unicorn['port'] = 8888
          nginx['listen_port'] = 80
      ports:
        - '80:80'
        - '443:443'
        - '2222:22'
      volumes:
        - ./config:/etc/gitlab
        - ./data:/var/opt/gitlab
        - ./logs:/var/log/gitlab

nexus

如果是做的本地数据卷映射,直接启动 Nexus 会有权限问题,我们通过如下命令手动创建数据卷目录

mkdir /usr/local/docker/nexus/data && chown -R 200 /usr/local/docker/nexus/data
version: '3.5'
services:
  nexus:
    restart: always
    image: sonatype/nexus3:3.23.0
    container_name: nexus
    environment:
      INSTALL4J_ADD_VM_PARAMS: -XX:ActiveProcessorCount=4
    ports:
      - 80:8081
    volumes:
      - ./data:/nexus-data

启动成功后访问 Nexus 服务器,默认账号密码如下:

默认账号:admin
默认密码:cat /usr/local/docker/nexus/data/admin.password

harbor

下载地址:https://github.com/goharbor/harbor/releases/download/v2.0.0/harbor-offline-installer-v2.0.0.tgz
可以用迅雷下载上传到服务器中
上传压缩包到服务器的 /usr/local/docker 目录下并解压

tar -zxvf harbor-offline-installer-v2.0.0.tgz

修改配置文件

cd harbor
cp harbor.yml.tmpl harbor.yml
vi harbor.yml
# 第 5 行,修改主机名为你本机ip或者自定义域名
hostname: ip

# 第 12 行,注释掉 HTTPS 的相关配置
# https related config
# https:
  # https port for harbor, default is 443
  # port: 443
  # The path of cert and key files for nginx
  # certificate: /your/certificate/path
  # private_key: /your/private/key/path

安装 Harbor

./install.sh

默认账号:admin
默认密码:Harbor12345

jenkins

version: '3.5'
services:
  jenkins:
    restart: always
    image: jenkins/jenkins:lts
    container_name: jenkins
    environment:
      TZ: Asia/Shanghai
    ports:
      - 80:8080
      - 50000:50000
    volumes:
      - data:/var/jenkins_home

volumes:
  data:

默认数据卷的位置在 /var/lib/docker/volumes 目录下
启动成功后访问容器
默认密码:

cat /var/lib/docker/volumes/jenkins_data/_data/secrets/initialAdminPassword

你可能感兴趣的:(用docker-compose搭建mysql,gitlab,nexus,harbor,jenkins)