docker run -d --name mongo-yapi mongo
docker pull registry.cn-hangzhou.aliyuncs.com/anoy/yapi
docker run -it --rm \
--link mongo-yapi:mongo \
--entrypoint npm \
--workdir /api/vendors \
registry.cn-hangzhou.aliyuncs.com/anoy/yapi \
run install-server
docker run -d \
--name yapi \
--link mongo-yapi:mongo \
--workdir /api/vendors \
-p 3000:3000 \
registry.cn-hangzhou.aliyuncs.com/anoy/yapi \
server/app.js
# 访问
http://192.168.120.18:3000
# 登录账号
admin@admin.com
# 密码
ymfe.org
# 1.安装pip
yum install epel-release
wget https://bootstrap.pypa.io/pip/2.7/get-pip.py
python get-pip.py
# 2.安装docker-compose
pip install docker-compose
# 3.升级包
yum upgrade python*
# 为了保证 mangodb 和 yapi 两个容器间可以互相通信,需要创建容器网络
docker network create --driver bridge --subnet=10.10.0.0/16 --gateway=10.10.0.1 yapi
# 创建工作目录并进入
mkdir /opt/yapi-compose && cd /opt/yapi-compose
vim mongodb-compose.yml
version: '3'
services:
mongodb:
image: mongo:4.4.4 # 镜像名
container_name: mongodb # 容器名
volumes: # 数据挂载目录;本地目录:容器目录
- /data/docker/volumes/yapi-mongodb:/data/db
ports:
- 27017:27017 # 端口,宿主机:容器
# environment:
# - COMPOSE_PROJECT_NAME=yapi
restart: always
# 设置默认网络
networks:
default:
external:
# 创建的容器网络名
name: yapi
vim yapi-compose.yml
version: '3'
services:
yapi:
image: jayfong/yapi:latest # 镜像名
container_name: yapi # 容器名
privileged: true # 赋予root权限
ports:
- 3000:3000 # 端口,宿主机:容器
environment:
- YAPI_ADMIN_ACCOUNT=admin@admin.com # 登入账号
- YAPI_ADMIN_PASSWORD=ymfe.org # 登入密码
- YAPI_CLOSE_REGISTER=true # 关闭注册功能
- YAPI_DB_SERVERNAME=mongodb # mongodb 数据库地址
- YAPI_DB_PORT=27017 # mongodb 端口
- YAPI_DB_DATABASE=yapi # mongodb 数据库名
- YAPI_MAIL_ENABLE=false # 不启用邮箱
- YAPI_LDAP_LOGIN_ENABLE=false # 不启用 loap 登入
- YAPI_PLUGINS=[] # 插件
# - COMPOSE_PROJECT_NAME=yapi
restart: always
# 设置默认网络
networks:
default:
external:
name: yapi
# 会自动下载docker镜像
docker-compose -p mongodb -f mongodb-compose.yml up -d
docker-compose -p yapi -f yapi-compose.yml up -d
# 访问
http://192.168.120.18:3000
# 登录账号
admin@admin.com
# 密码
ymfe.org