利用Docker创建内网开发环境
服务器地址:192.168.1.200
为docker创建内部通讯网络
docker network create common-network
安装mongo
docker run -itd --name mongo -v /data/docker_data/mogodb/data:/data/db -p 27017:27017 mongo --auth
连接mongo
docker exec -it mongo mongosh admin
创建一个名为 admin,密码为 123456 的用户。
db.createUser({ user:'admin',pwd:'123456',roles:[ { role:'userAdminAnyDatabase', db: 'admin'},"readWriteAnyDatabase"]});
尝试使用上面创建的用户信息进行连接。
db.auth('admin', '123456')
安装mariadb
docker pull mariadb
启动mariadb
docker run -d -p 3306:3306 -v /data/docker_data/mysql/data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD="123456" --name mariadb mariadb
安装redis
拉取镜像
docker pull redis:latest
启动
docker run -p 6379:6379 --name redis -v /data/docker_data/redis/data:/data -v /data/docker_data/redis/conf/redis.conf:/etc/redis/redis.conf --restart=always --network common-network -d redis redis-server /etc/redis/redis.conf
简单创建与启动
docker run -itd --name redis-6379 -p 6379:6379 redis --requirepass 123456
rocketmq
docker run -itd --name rocketmq_namesrv --restart=always -p 9876:9876 -v /data/docker_data/rocketmq/namesrv:/home/rocketmq rocketmqinc/rocketmq:latest sh mqnamesrv autoCreateTopicEnable=true docker run -d -p 10911:10911 -p 10909:10909 --restart=always -v /data/rocketmq/broker:/home/rocketmq:rw -v /deploy/etc/rocketmq-broker.conf:/opt/rocketmq-4.4.0/conf/broker.conf \ -v /etc/localtime:/etc/localtime:ro \ --name rocketmq_broker -e "NAMESRV_ADDR=192.168.1.100:9876" \ -e "MAX_POSSIBLE_HEAP=200000000" \ rocketmqinc/rocketmq:4.4.0 sh mqbroker autoCreateTopicEnable=true -c /opt/rocketmq-4.4.0/conf/broker.conf