docker容器下安装redis、mysql、mongodb、nginx

docker run --restart=always --log-opt max-size=100m --log-opt max-file=2 -p 6379:6379 --name myredis -v /opt/redis/myredis/myredis.conf:/etc/redis/redis.conf -v /opt/redis/myredis/data:/data -d redis redis-server /etc/redis/redis.conf  --appendonly yes  --requirepass root123

#docker run -d --restart=always -p 27017:27017 --name mymongo -v /data/db:/data/db -d mongo


#docker run -it -m 300M --memory-reservation 200M -p 3306:3306 --name mysql -e MYSQL_ROOT_PASSWORD=root123 mysql /bin/bash


 docker run -d -p 3306:3306 -v /opt/mysql/conf:/etc/mysql/conf.d -v /opt/mysql/data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=root123 -d mysql:5.7



docker run --name mongodb -p 27017:27017  -v /opt/mongodb/data:/data/db -v /opt/mongodb/backup:/data/backup -d mongo --auth

use admin  
db.createUser({
  user: 'admin',  // 用户名
  pwd: 'root123',  // 密码
  roles:[{
    role: 'root',  // 角色---超级管理员才可以使用该角色
    db: 'yygh_hosp'  // 数据库
  }]
})

db.createUser({ 
    user: "admin", 
    pwd: "root123", 
    roles: [ { role: "root", db: "admin" } ], 
    mechanisms : ["SCRAM-SHA-1"] 
})


docker pull rabbitmq:management
docker run -d -p 5672:5672 -p 15672:15672 --name rabbitmq rabbitmq:management




docker pull nginx
docker run --name nginx -p 8081:80 -d nginx
# 将容器nginx.conf文件复制到宿主机
docker cp nginx:/etc/nginx/nginx.conf /MyDockerContiner/nginx/conf/nginx.conf
# 将容器conf.d文件夹下内容复制到宿主机
docker cp nginx:/etc/nginx/conf.d /MyDockerContiner/nginx/conf/conf.d
# 将容器中的html文件夹复制到宿主机
docker cp nginx:/usr/share/nginx/html /MyDockerContiner/nginx/


docker run -p 8081:80 --name nginx -v /MyDockerContiner/nginx/conf/nginx.conf:/etc/nginx/nginx.conf -v /MyDockerContiner/nginx/conf/conf.d:/etc/nginx/conf.d -v /MyDockerContiner/nginx/html:/usr/share/nginx/html -d nginx

你可能感兴趣的:(docker,redis,mysql)