临时需要在公司内网搭一个看板工具。

    找了半天wekan比较合适。多余的介绍不记录。

    网上,包括官网文档都是提供如下命令

    docker run -d --restart=always --name wekan-db mongo:4.0
    
    docker run -d --restart=always --name wekan --link "wekan-db:db" -e "WITH_API=true" -e "MONGO_URL=mongodb://db" -e "ROOT_URL=http://192.168.1.200:2000" -p 2000:8080 quay.io/wekan/wekan
    

    但是这样是不行的,启动以后wekan容器报错,看日志会出现:

    /build/programs/server/node_modules/fibers/future.js:313
    
    throw(ex);
    
    ^
    
    2019-11-27T08:15:08.309299100Z 
    
    MongoError: database name must be a string
    
        at Function.create (/build/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb-core/lib/error.js:43:12)
    
        at validateDatabaseName (/build/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/operations/db_ops.js:720:22)
    
        at new Db (/build/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/db.js:182:3)
    
        at MongoClient.db (/build/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/mongo_client.js:237:14)
    
        at packages/mongo/mongo_driver.js:186:25
    
        at runWithEnvironment (packages/meteor.js:1286:24)
    
    /build/programs/server/node_modules/fibers/future.js:313
    
    throw(ex);
    
    ^
    
    2019-11-27T08:15:11.422765500Z 
    
    MongoError: database name must be a string
    
        at Function.create (/build/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb-core/lib/error.js:43:12)
    
        at validateDatabaseName (/build/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/operations/db_ops.js:720:22)
    
        at new Db (/build/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/db.js:182:3)
    
        at MongoClient.db (/build/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/mongo_client.js:237:14)
    
        at packages/mongo/mongo_driver.js:186:25
    
        at runWithEnvironment (packages/meteor.js:1286:24)
    

    刚一看一脸懵逼,各种说mongo版本不对,或者版本不匹配的问题。
    其实很简单就是MONGO_URL写错了。

    –link “wekandb-db:db” 意思是将当前的容器连接名字为wekan-db的容器,在当前里面通过“:”后面的db作为host访问。所以MONGO_URL给的是:mongodb://db(host) 缺少了db名字。写为:mongodb://db(host)/db(database name)就行了。

    防止产生意义上的混淆,记录一下创建方式。

    
    # MongoDB
    
    docker run -d --restart=always -v ~/dockerfile/mongodb/configdb:/data/configdb -v ~/dockerfile/mongodb/db:/data/db --name wekan-db mongo
    
    #Wekan
    
    docker run -d --restart=always --name wekan --link "wekan-db:wekandb" -e "WITH_API=true" -e "MONGO_URL=mongodb://wekandb/db" -e "ROOT_URL=http://192.168.0.11:2000" -p 2000:8080 wekanteam/wekan