Docker Devops---Git和MySql構建持續整合的版本控制和資料庫環境
阿新 • • 發佈:2021-11-17
安裝Git和MySql構建持續整合的版本控制和資料庫環境
1.安裝docker
安裝docker,docker源自行配置
[root@mywang ~]# yum -y install docker-ce
開啟 iptables轉發功能
[root@mywang ~]# cat /etc/sysctl.conf
# sysctl settings are defined through files in
# /usr/lib/sysctl.d/, /run/sysctl.d/, and /etc/sysctl.d/.
#
# Vendors settings live in /usr/lib/sysctl.d/.
# To override a whole file, create a new file with the same in
# /etc/sysctl.d/ and put new settings there. To override
# only specific settings, add a file with a lexically later
# name in /etc/sysctl.d/ and put new settings there.
#
# For more information, see sysctl.conf(5) and sysctl.d(5).
net.ipv4.ip_forward = 1
net.bridge.bridge-nf-call-iptables = 1
net.bridge.bridge-nf-call-ip6tables = 1
[root@mywang ~]# modprobe br_netfilter
[root@mywang ~]# sysctl -p
net.ipv4.ip_forward = 1
net.bridge.bridge-nf-call-iptables = 1
net.bridge.bridge-nf-call-ip6tables = 1
啟動並設定開機自啟
[root@mywang ~]# systemctl start docker
[root@mywang ~]# systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
2.拉取映象
拉取映象
[root@mywang ~]# docker pull gogs/gogs && docker pull mysql
啟動容器
[root@mywang ~]# docker run -itd -p 81:3000 --name=gogs gogs/gogs:latest
c16a482e29617b5f91b75693952f53443da81f70eb159383695aee43bd6514a7
[root@mywang ~]# docker run -itd -p 13306:3306 -e MYSQL_ROOT_PASSWORD=123 --name=gogs-mysql mysql
0735ae246113ebd61cdf9be7a90e73d241b8ff9d1ce4aa81f7c46a466556e626
3.建立資料庫
進入容器,建立資料庫gogs
[root@mywang ~]# docker exec -it gogs-mysql /bin/bash
root@0735ae246113:/# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.27 MySQL Community Server - GPL
Copyright (c) 2000, 2021, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> create database gogs;
Query OK, 1 row affected (0.01 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| gogs |
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
5 rows in set (0.05 sec)
mysql> exit
Bye
在網頁登入gogs服務 ,配置資料庫資訊,點選安裝
##建議將域名和應用url改成自己終端的ip,不然網頁會跳轉到宿主機的http://localhost:81/user/login
進行使用者註冊並登入
建立新的倉庫
安裝git,複製Git庫到本地/opt目錄,構建私有倉庫。
[root@mywang opt]# yum -y install git
[root@mywang opt]# git clone http://10.66.48.37:81/root/repository01.git
Cloning into 'repository01'...
warning: You appear to have cloned an empty repository.
[root@mywang opt]#