效果:
docker-compose
version: "3"
networks:
gitea:
external: false
services:
server:
image: gitea/gitea:latest
container_name: gitea
environment:
- USER_UID=1000
- USER_GID=1000
- DB_TYPE=mysql
- DB_HOST=db:3306 #连接mysql的地址,这里写mysql的服务名称
- DB_NAME=gitea
- DB_USER=gitea
- DB_PASSWD=gitea
restart: always
networks:
- gitea
volumes:
- ./data:/data
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
ports:
- "3000:3000"
- "222:22"
depends_on:
- db
db:
image: mysql:5.7
restart: always
environment:
- MYSQL_ROOT_PASSWORD=gitea
- MYSQL_USER=gitea
- MYSQL_PASSWORD=gitea
- MYSQL_DATABASE=gitea
networks:
- gitea
volumes:
- ./mysql:/var/lib/mysql
docker-compose up -d
docker-comopse down
修改这个app.ini文件
vim gitea/data/gitea/conf/app.ini
这里我们将配置文件的ssh端口修改222,不仅这里,我们还要修改我们yml中的映射端口
重启
docker-compose restart
宿主机222映射到docker222端口,接下里我们测试拉代码
参考文档:
https://blog.csdn.net/weixin_38982591/article/details/109288454
啦啦啦,成功了