Docker Devops---Git(gags)和MySql构建持续集成的版本控制和数据库环境

Docker DevOps(一)

本文来自博客园,作者:君邪不邪,转载请注明原文链接:Docker Devops---Git(gags)和MySql构建持续集成的版本控制和数据库环境 - 君邪不邪 - 博客园 (cnblogs.com)

安装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]#

 

 

 

posted @ 2021-11-17 20:00  君邪不邪  阅读(151)  评论(0编辑  收藏  举报