ubuntu 中搭建docker,并部署jenkins、yapi、蝉道基础开发服务
1、安装docker
sudo df -hl
sudo apt update sudo apt upgrade sudo wget -qO- https://get.docker.com/ | sh
2、配置docker
sudo usermod -aG docker $USER sudo systemctl start docker sudo service docker restart
sudo docker run hello-world
sudo mkdir -p /data
sudo chmod 777 /data
cd /data
mkdir -p docker/yapi
mkdir -p docker/jenkins
mkdir -p docker/zendao
sudo ln -s /data/docker ~/docker
3、docker中部署yapi
cd /data/docker/yapi vim docker-compose.yml
输入下面的内容,wq保存
version: '3.7' services: yapi-web: image: jayfong/yapi:latest container_name: yapi-web ports: - 3001:3000 environment: - YAPI_ADMIN_ACCOUNT=815404329@qq.com - YAPI_ADMIN_PASSWORD=815404329 - YAPI_CLOSE_REGISTER=false - YAPI_DB_SERVERNAME=yapi-mongo - YAPI_DB_PORT=27017 - YAPI_DB_DATABASE=yapi - YAPI_MAIL_ENABLE=true - YAPI_LDAP_LOGIN_ENABLE=false - YAPI_PLUGINS=[] depends_on: - yapi-mongo links: - yapi-mongo restart: unless-stopped yapi-mongo: image: mongo:latest container_name: yapi-mongo volumes: - ./data/db:/data/db expose: - 27017 restart: unless-stoppe
sudo docker-compose up -d 启动yapi
在浏览器中打开网址: http://localhost:3001/
输入账号:815404329@qq.com
输入密码:815404329
4、docker中部署蝉道
cd /data/docker/zendao vim docker-compose.yml
输入下面的内容,wq保存
version: '3.7' services: zendao: image: docker.io/idoop/zentao:latest restart: always container_name: zendao environment: MYSQL_ROOT_PASSWORD: "815404329@qq.com" ADMINER_USER: "root" ADMINER_PASSWD: "815404329" BIND_ADDRESS: "false" ports: - 8001:80 - 13306:3306 volumes: - ./app:/app/zentaopms - ./zentao:/opt/zentao - ./mysql:/opt/zbox/data/mysql
sudo docker-compose up -d 启动yapi
在浏览器中打开网址: http://localhost:8001/
输入账号:root
输入密码:815404329
5、docker中部署jenkins
cd /data/docker/jenkins vim docker-compose.yml
输入下面的内容,wq保存
version: "3.7" services: # 集合 docker_jenkins: user: root # 为了避免一些权限问题 在这我使用了root privileged: true restart: always # 重启方式 image: jenkins/jenkins:lts # 指定服务所使用的镜像 在这里我选择了 LTS (长期支持) container_name: jenkins # 容器名称 ports: # 对外暴露的端口定义 - 8081:8080 # 访问Jenkins服务端口 - 50001:50000 environment: TZ: Asia/Shanghai volumes: # 卷挂载路径 - ./data:/var/jenkins_home - /var/run/docker.sock:/var/run/docker.sock - /usr/bin/docker:/usr/bin/docker # 这是为了我们可以在容器内使用docker命令 - /usr/local/bin/docker-compose:/usr/local/bin/docker-compose
sudo docker-compose up -d 启动yapi
sudo docker ps -a 查看启动的所有镜像
在浏览器中打开网址: http://localhost:8081/