使用docker搭建私服gogs
官方文档:Gogs官网文档地址
1.docker安装mysql(如果已经有了数据库就不需要安装了)
- 拉取mysql镜像
docker pull mysql
- 创建物理目录,用于存储mysql数据
mkdir /opt/docker/mysql/data //mysql数据文件目录 mkdir /opt/docker/mysql/conf //mysql配置文件目录
- 配置文件目录下新增文件 docker.cnf, mysql.cnf, mysqldump.cnf 。分别为文件追加内容
[mysqld]
skip-host-cache skip-name-resolve[mysql] default-character-set = utf8 [mysql_safe] default-character-set = utf8 [client] default-character-set = utf8 [mysqld] pid-file = /var/run/mysqld/mysqld.pid socket = /var/run/mysqld/mysqld.sock datadir = /var/lib/mysql #log-error = /var/log/mysql/error.log # By default we only accept connections from localhost #bind-address = 127.0.0.1 # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 # 修改mysql默认字符集 init_connect = 'SET NAMES utf8' character-set-server = utf8 collation-server = utf8_unicode_ci
[mysqldump] quick quote-names max_allowed_packet = 16M
- 启动mysql
docker run -d --name gogs-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=root -v /opt/docker/mysql/data:/var/lib/mysql -v /opt/docker/mysql/conf:/etc/mysql/conf.d mysql:latest
- 查看是否 启动成功 docker ps -a
2.docker 安装 gogs
- 拉取镜像:
docker pull gogs/gogs
- 创建物理目录:
mkdir /opt/docker/gogs
-
启动:
docker run -d --name=mygogs -p 10022:22 -p 10080:3000 -v /opt/docker/gogs:/data gogs/gogs
3.配置gogs
- 浏览器访问物理机ip+端口 ip:10080
- 设置数据库配置,修改个人的配置信息:主机、用户、密码、数据库 等配置信息
- 设置应用访问配置,域名使用物理机ip地址+端口:192.168.3.61:10080,ssh端口号:10022,应用url:192.168.3.61:10080
- 设置管理员信息