本文共 1744 字,大约阅读时间需要 5 分钟。
一. 准备镜像:(从DockerHub下载)
gogs:0.11.53 mysql:5.7
二. 运行容器
**注意卷的挂载以及端口的暴露**example: 1> 运行gog容器, 3000端口是Web页面端口,22是用户ssh方式访问git服务的端口 docker run -d -p 3000:3000 -p 2222:22 -v /root/gogs/gogsdata:/data -v /etc/localtime:/etc/localtime gogs/gogs:0.11.53 2> 运行mysql容器,用于存储gogs数据库,注意设置密码和服务器编码 docker run --privileged --name mysql -p 3306:3306 -v /root/gogs/mysqldata:/var/lib/mysql -v /etc/localtime:/etc/localtime -e MYSQL_ROOT_PASSWORD=Paic1234 -d mysql:5.7 --character-set-server=utf8
三. 登录mysql容器创建gogs数据库
[root@SZD-L0103739 gogs]# docker ps | grep mysql 1d8830a5b3a9 mysql:5.7 "docker-entrypoint..." 13 days ago Up 13 days 0.0.0.0:3306->3306/tcp mysql [root@SZD-L0103739 gogs]# docker exec -it 1d88 bash root@1d8830a5b3a9:/# mysql -h 127.0.0.1 -uroot -pPaic1234 ### 1. 登录Mysql mysql: [Warning] Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 63 Server version: 5.7.22 MySQL Community Server (GPL) Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. 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> set names utf8; #### 2. 设置编码 Query OK, 0 rows affected (0.00 sec) mysql> create database gogs; ### 3. 创建数据库 ERROR 1007 (HY000): Can't create database 'gogs'; database exists mysql>
四. 登录Gog Web界面进行配置:
转载地址:http://bclzl.baihongyu.com/