sudo yum update
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
sudo yum-config-manager --add-repo http://mirrors.ustc.edu.cn/docker-ce/linux/centos/docker-ce.repo
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
sudo yum install -y docker-ce
docker -v
#开机自启动
systemctl enable docker
docker system prune -a -f
systemctl restart docker.service
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
#国内资源(建议)
curl -L https://get.daocloud.io/docker/compose/releases/download/1.25.4/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
# 设置文件可执行权限
chmod +x /usr/local/bin/docker-compose
# 查看版本信息
docker-compose -version
mkdir mongo
cd mongo
vi docker-compose.yml
version: '3.1'
services:
mongo:
image: mongo:5.0.2
restart: always
container_name: mongo
hostname: mongo
environment:
#用户名密码
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: root
ports:
- 27017:27017
volumes:
- ./data:/data/db
networks:
mongo:
aliases:
- mongo1
networks:
mongo:
driver: bridge
docker-compose up -d
安装完后,要对mongo进行认证操作cls
进入mongo内部
[root@localhost ~]# docker exec -it mongo /bin/bash
root@mongo:/# mongo
MongoDB shell version v4.4.5
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("f7c7c594-d5dd-473a-9ded-43609ac16a28") }
MongoDB server version: 4.4.5
> use admin
switched to db admin
> db.auth("root","root")
1
> show dbs
admin 0.000GB
config 0.000GB
local 0.000GB
mkdir yapi
cd yapi
vi docker-compose.yml
version: '3'
services:
tanhua-yapi-web:
image: jayfong/yapi:latest
container_name: tanhua-yapi-web
ports:
- 3000:3000
environment:
- YAPI_ADMIN_ACCOUNT=admin@docker.yapi
- YAPI_ADMIN_PASSWORD=admin
- YAPI_CLOSE_REGISTER=true
- YAPI_DB_SERVERNAME=192.168.31.81
- YAPI_DB_PORT=27017
- YAPI_DB_DATABASE=yapi
- YAPI_DB_USER=root
- YAPI_DB_PASS=root
- YAPI_DB_AUTH_SOURCE=admin
- YAPI_MAIL_ENABLE=false
- YAPI_LDAP_LOGIN_ENABLE=false
- YAPI_PLUGINS=[]
restart: unless-stopped
注意 :
yapi依赖于mongodb数据库 , 所以要先运行mongodb容器
配置中的数据库地址 , 用户名和密码要改成自己的
docker-compose up -d