Docker-Compose部署YApi教程

Docker-Compose部署yapi教程

1. 环境

  • Ubuntu 20以上
  • Docker version 20以上
  • Docker-Compose version 1.25以上
    安装Docker和Docker-Compose教程

2. 创建YApi的docker-compose.yml文件

version: '3'
services:
  yapi-mongo:
    image: mongo:latest
    # 容器名称
    container_name: standalone-mongo
    #挂载 宿主机路径:容器路劲
    volumes:
      - /home/data/mongo/data:/data/db
    environment:
      #MongoDB账户
      MONGO_INITDB_ROOT_USERNAME: root
      #MongoDB密码
      MONGO_INITDB_ROOT_PASSWORD: [email protected]
    expose:
      - 27017 
  yapi:
    image: jayfong/yapi:1.9.1
    # 容器名称
    container_name: standalone-yapi
    ports:
      - 3000:3000
    environment:
      #自定义账户 注意只能是邮箱或正常账号 如 [email protected] 、 account
      YAPI_ADMIN_ACCOUNT: [email protected]
      # 自定义账户密码
      YAPI_ADMIN_PASSWORD: [email protected]
      YAPI_CLOSE_REGISTER: 'true'
      # yapi MongoDB服务名称
      YAPI_DB_SERVERNAME: yapi-mongo
      # yapi MongoDB端口号
      YAPI_DB_PORT: 27017
      # yapi MongoDB数据库名称
      YAPI_DB_DATABASE: yapi
      # yapi MongoDB账户
      YAPI_DB_USER: root
      # yapi MongoDB密码
      YAPI_DB_PASS: [email protected]
      # yapi MongoDB权限
      YAPI_DB_AUTH_SOURCE: admin
      YAPI_MAIL_ENABLE: 'false'
      YAPI_LDAP_LOGIN_ENABLE: 'false'
    depends_on:
      - yapi-mongo
    restart: always

3. 在docker-compose.yml文件当前文件夹启动

docker-compose up -d

4. 启动成功后,就可以用ip+端口访问啦

你可能感兴趣的:(docker,docker,mongodb,容器)