命令
- 拉鏡像
docker pull registry.cn-hangzhou.aliyuncs.com/anoy/yapi
- mongodb
sudo docker pull registry.cn-hangzhou.aliyuncs.com/anoy/yapi
docker run --restart always -v /var/www/yapi/mongodata:/data/db -d --name yapimongo mongo
- 運(yùn)行容器初始化
docker run -it --rm --link yapimongo:mongo --entrypoint npm --workdir /api/vendors registry.cn-hangzhou.aliyuncs.com/anoy/yapi run install-server
- 運(yùn)行服務(wù)
docker run -d --restart=always --name yapi --link yapimongo:mongo --workdir /api/vendors -p 3001:3000 registry.cn-hangzhou.aliyuncs.com/anoy/yapi server/app.js
- 初始化密碼
docker exec -it yapi /bin/sh
vi ../config.json
#修改內(nèi)容如下
{
"port": "3000",
"adminAccount": "admin@admin.com",
"closeRegister":true, #主要是添加這句配置
"db": {
"servername": "mongo",
"DATABASE": "yapi",
"port": 27017
}
}
#保存后退出
exit #退出容器
docker restart yapi #重啟服務(wù)
訪問 http://localhost:3000 登錄賬號(hào) admin@admin.com俗孝,密碼 ymfe.org
參考
https://www.cnblogs.com/binz/p/12684610.html
https://www.cnblogs.com/wenhainan/p/12850691.html