docker 安装 leanote
- 下载 leanote 安装包
在 https://github.com/leanote/leanote/releases,下载最新版本 leanote
当前版本:leanote-linux-amd64-v2.6.1.bin.tar.gz
- 下载 mongo 镜像
docker pull mongo:latest
- 建立容器,并开启认证
docker run -itd -p 27017:27017 --restart=always --name mongo -v /home/mongo:/data/db mongo --auth
- 解压 leanote-linux-amd64-v2.6.1.bin.tar.gz
tar zxvf leanote-linux-amd64-v2.6.1.bin.tar.gz
- 把 leanote 初始化数据放入 docker
docker cp leanote/mongodb_backup/leanote_install_data mongo:/
- 建立 mongo 的全局管理员,username: admin,password: abc123
docker exec -it mongo mongo
use admin;
db.createUser({ user:'admin',pwd:'abc123',roles:[ { role:'userAdminAnyDatabase', db: 'admin'},"readWriteAnyDatabase"]});
exit
- 对 mongo 进行初始化
docker exec -it mongo mongorestore -h localhost -d leanote --drop --dir /leanote_install_data/ --authenticationDatabase admin -u admin -p 'abc123'
- 建立 leanote 数据库管理员,username: leanote,password: leanote123
docker exec -it mongo mongo -u "admin" -p "abc123" --authenticationDatabase "admin"
use leanote;
db.createUser({user: 'leanote', pwd: 'leanote123', roles: [{role: 'dbOwner', db: 'leanote'}]});
exit
- 下载 leanote 镜像
docker pull cnkmmk/leanote:2.6.1
- 修改配置文件
mkdir -p /home/leanote/{conf,files}
cp leanote/conf/* /home/leanote/conf/
docker inspect mongo | grep IPAddress
sed -i 's/^db.host=127.0.0.1/db.host=172.17.0.2/g' /home/leanote/conf/app.conf
sed -i 's/^db.username= #/db.username=leanote #/g' /home/leanote/conf/app.conf
sed -i 's/^db.password= #/db.password=leanote123 #/g' /home/leanote/conf/app.conf
- 启动容器
docker run -itd -p 9000:9000 --restart=always -v /home/leanote/conf:/leanote/conf -v /home/leanote/files:/leanote/files --name leanote leanote:latest
初始用户
username: admin
password: abc123关闭注册使用
后台管理 -> confiration -> Open Register
以后要加入其它人员,用管理员人工加入