一、拉取Gogs的镜像
docker pull gogs/gogs
拉取镜像的效果
二、运行Gogs
docker run
docker run -d --name=gogs --restart=always -p 8031:3000 -p 8032:22 -v /docker/gogs:/data gogs/gogs
运行Gogs
--restart=alwaysdocker update --restart=always
-
备选(非Linux环境) :
1、设置好Shared Drives,如下图。如果修改了系统用户密码,需要重新认证,Reset credentials 后输入系统用户密码即可。如果执行命令报错,则需要重启电脑
Shared Drives设置
docker run -d --name=gogs --restart=always -p 8031:3000 -p 8032:22 -v /d/Docker/Container_Data/gogs:/data gogs/gogs
docker-compose
version: "3"
services:
gogs_stack:
image: gogs/gogs
ports:
- "22:22"
- "3000:3000"
restart: always
volumes:
- ./data:/data/docker/gogs
container_name: gogs
network_mode: "bridge"
docker-compose up -d
version: "3"
services:
mysql:
image: mysql
container_name: gogs_mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: 123456
MYSQL_DATABASE: gogs
ports:
- "10036:3306"
volumes:
- ./mysql/config:/etc/mysql/conf.d
- ./mysql/db:/var/lib/mysql
- ./mysql/conf/my.cnf:/etc/my.cnf
- ./mysql/init:/docker-entrypoint-initdb.d/
networks:
gogs_app:
aliases:
- mysql
gogs:
image: gogs/gogs
container_name: gogs
restart: always
ports:
- "10080:3000"
- "10022:22"
depends_on:
- mysql
volumes:
- ./data:/data
networks:
gogs_app:
aliases:
- gogs_main
networks:
gogs_app:
三、配置Gogs
docker psdocker inspect mysql
docker ps和docker inspect mysql执行详情
tips:如果MySQL不配置为网关地址,可能会出现的错误。
1、数据库设置不正确:dial tcp 127.0.0.1:13306: getsockopt: connection refused
2、Database setting is not correct: dial tcp 127.0.0.1:13306: getsockopt: connection refused
docker inspect mysql执行详情
2、开始安装Gogs
图片.png
图片.png
配置完成后可以通过此地址访问Gogshttp://localhost:8031
3、配置app.ini
REGISTER_EMAIL_CONFIRM = false
ENABLE_NOTIFY_MAIL = false
DISABLE_REGISTRATION = true//不允许注册,也就是不对外开发git服务
ENABLE_CAPTCHA = true
REQUIRE_SIGNIN_VIEW = true//默认是登录页
配置完需要重启gogs,配置才可以生效。
参考地址:
1、配置详情https://cloud.tencent.com/developer/article/1350453
2、解决无法在Gogs中配置MySQLhttp://einverne.github.io/post/2018/03/gogs.html