本节目标
安装 docker
启动 yapi
备份、恢复 yapi
正文 安装 Windows 10 专业工作站版
https://msdn.itellyou.cn/
安装 docker
https://www.docker.com/
阿里镜像加速
https://cr.console.aliyun.com/cn-zhangjiakou/instances/mirrors
1 2 3 4 5 6 { "registry-mirrors" : ["https://你的代码.mirror.aliyuncs.com" ], "insecure-registries" : [], "debug" : true , "experimental" : true }
docker-compose 配置 yapi
1 PASSWORD=$V7iTNk5N8#AkOeiwO@BywzBFte2^WsAuI$eJ4k9CKV0riqe
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 version: "3" services: mongo-yapi: image: mongo container_name: mongo-ypai restart: always environment: - TZ=Asia/Shanghai - MONGO_INITDB_DATABASE=yapi volumes: - mongo-data:/data/db networks: docker_net: ipv4_address: 172.22 .0 .11 web-yapi: image: jayfong/yapi:latest container_name: web-ypai restart: always ports: - 3000 :3000 depends_on: - mongo-yapi links: - mongo-yapi environment: - TZ=Asia/Shanghai - YAPI_ADMIN_ACCOUNT=admin@ducafecat.tech - YAPI_ADMIN_PASSWORD=${PASSWORD} - YAPI_CLOSE_REGISTER=true - YAPI_DB_SERVERNAME=mongo-yapi - YAPI_DB_PORT=27017 - YAPI_DB_DATABASE=yapi - YAPI_MAIL_ENABLE=false - YAPI_LDAP_LOGIN_ENABLE=false - YAPI_PLUGINS=[] networks: docker_net: ipv4_address: 172.22 .0 .12 volumes: mongo-data: networks: docker_net: driver: bridge ipam: config: - subnet: 172.22 .0 .0 /16
启动、卸载 ypai 服务
本地域名解析
C:\Windows\System32\drivers\etc\hosts
1 127.0.0.1 api.news.ducafecat.tech
查询 volume 1 2 3 4 5 $ docker volume ls DRIVER VOLUME NAME local 2fc91e2fd47a7110c2ecc5c8b88b997c4e6ddcf471a1df04f3fb618238ffd8aalocal 26e58cd678a97108f6dcd2cab33b9de341f992ceedacb7fd772c196bec908306local yapi-volumes_mongo-data
备份数据 1 $ docker run --rm --volumes-from mongo-ypai -v c:\backup:/backup ubuntu tar cvf /backup/backup.tar -C /data/db .
还原数据 1 $ docker run --rm --volumes-from mongo-ypai -v c:\backup:/backup ubuntu bash -c "cd /data/db && tar xvf /backup/backup.tar -C /data/db "
资源 参考
视频 代码 https://github.com/ducafecat/docker-yapi.git
© 猫哥
https://ducafecat.tech
邮箱 ducafecat@gmail.com / 微信 ducafecat / 留言板 disqus