目录
Docker安装Gogs
官方链接:https://github.com/gogs/gogs/tree/main/docker
环境:centos7
1、创建docker网络
docker network create net-test
2、安装启动gogs服务
mkdir -p /var/gogs
//加入刚才创建的net-test网络,挂载本地的/var/gogs文件夹
docker run -itd --name=gogs --network net-test -p 10022:22 -p 3000:3000 -v /var/gogs:/data gogs/gogs
//查看服务日志
docker logs gogs
3、安装启动mysql
docker run -itd --name mysql-test -p 13306:3306 -e MYSQL_ROOT_PASSWORD=123456 --network net-test mysql:5.7
docker exec -it mysql-test /bin/bash
mysql -h localhost -u root -p
4、创建gogs数据库
mysql.sql
SET @s = IF(version() < 8 OR (version() LIKE '%MariaDB%' AND version() < 10.3),
'SET GLOBAL innodb_file_per_table = ON,
innodb_file_format = Barracuda,
innodb_large_prefix = ON;',
'SET GLOBAL innodb_file_per_table = ON;');
PREPARE stmt1 FROM @s;
EXECUTE stmt1;
DROP DATABASE IF EXISTS gogs;
CREATE DATABASE IF NOT EXISTS gogs CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
5、创建mysql的gogs用户,并赋予gogs库的权限
# mysql容器内执行,'gogs'@'%'不限制登录的host
mysql -h localhost -u root -p (123456)
> mysql grant all privileges on gogs.* to 'gogs'@'%' identified by '123456';
> mysql flush privileges;
> mysql exit;
6、创建系统用户
groupadd git
useradd git -g docker
7、配置gogs
配置完成后即可注册登录,默认第一个注册的用户为管理员
如有不对,烦请指出,感谢~