一、redis
创建/root/redis/conf/redis.conf
- bind 0.0.0.0
- protected-mode yes
- port 6379
- tcp-backlog 511
- timeout 0
- tcp-keepalive 0
- loglevel notice
- logfile ""
- databases 4
- save 900 1
- save 300 10
- save 60 10000
- stop-writes-on-bgsave-error yes
- rdbcompression yes
- rdbchecksum yes
- dbfilename dump.rdb
- dir ./
- requirepass 123456
全部执行命令如下
docker run -it -d --name redis -p 6379:6379 --net mynet --ip 172.18.0.9 -m 400m -v /root/redis/conf:/usr/local/etc/redis -e TX=Asia/Shangehai redis redis-server /usr/local/etc/redis/redis.conf
部署成功,用工具连接
docker下的redis修改配置,https://blog.51cto.com/u_16213346/10957845
二、mongoDB
- #安装镜像
- docker search mongodb
- docker pull mongo
-
- #创建容器
- docker run -it -d --name mongo -p 27017:27017 --net mynet --ip 172.18.0.10 -m 800m -v /root/mongo:/etc/mongo -v /root/mongo/data/db:/data/db -e MONGO_INITDB_ROOT_USERNAME=admin -e MONGO_INITDB_ROOT_PASSWORD=****** -e TZ=Asia/Shanghai mongo
-
- #查看运行态
- docker ps -a
- docker logs -f mongo
-
- #进容器查看数据
- docker exec -it mongo bash
-
- #进入容器后,查看mongo数据
- $ mongosh --host 127.0.0.1 --port 27017
-
- #其他操作,停止或启动服务与删除容器
- docker stop mongo
- docker start mongo
-
- docker rm mongo