Mysql
docker pull mysql:5.7
mkdir -p /usr/local/dockerdata/mall-mysql/log
mkdir -p /usr/local/dockerdata/mall-mysql/data
mkdir -p /usr/local/dockerdata/mall-mysql/conf
docker run --restart always -p 8306:3306 --name mall-mysql \
-v /usr/local/dockerdata/mall-mysql/log:/var/log/mysql \
-v /usr/local/dockerdata/mall-mysql/data:/var/lib/mysql \
-v /usr/local/dockerdata/mall-mysql/conf:/etc/mysql \
-e MYSQL_ROOT_PASSWORD=root \
-d mysql:5.7
vim mall.sql #sql语句连接
docker cp /mydata/mall.sql mall-mysql:/
docker exec -it mall-mysql /bin/bash
#登录mysql
mysql -uroot -proot --default-character-set=utf8
create database mall character set utf8
use mall
source /mall.sql
#创建⼀个reader帐号并修改权限,使得任何ip都能访问:
grant all privileges on *.* to 'reader' @'%' identified by '123456'
Redis
docker pull redis:3.2
mkdir -p /usr/local/dockerdata/redis/data
docker run --restart always -p 6379:6379 --name mall-redis \
-v /usr/local/dockerdata/redis/data:/data \
-d redis:3.2 redis-server --appendonly yes
Nginx
docker pull nginx:1.10
mkdir -p /usr/local/dockerdata/mall-nginx/html
mkdir -p /usr/local/dockerdata/mall-nginx/logs
mkdir -p /usr/local/dockerdata/mall-nginx/conf
docker run -p 80:80 --name mall-nginx \
-v /usr/local/dockerdata/mall-nginx/html:/usr/share/nginx/html \
-v /usr/local/dockerdata/mall-nginx/logs:/var/log/nginx \
-d nginx:1.10
#将容器内的配置⽂件拷⻉到指定⽬录
docker container cp mall-nginx:/etc/nginx /usr/local/dockerdata/mall-nginx
#修改⽂件名称
mv /usr/local/dockerdata/mall-nginx/nginx /usr/local/dockerdata/mall-nginx/conf
#删除重启nginx
docker stop mall-nginx
docker rm mall-nginx
docker run --restart always -p 80:80 --name mall-nginx \
-v /usr/local/dockerdata/mall-nginx/html:/usr/share/nginx/html \
-v /usr/local/dockerdata/mall-nginx/logs:/var/log/nginx \
-v /usr/local/dockerdata/mall-nginx/conf/nginx:/etc/nginx \
-d nginx:1.10
RabbitMQ
docker pull rabbitmq:3.7.15
docker run --restart always -d --name rabbitmq \
--publish 5671:5671 --publish 5672:5672 --publish 4369:4369 \
--publish 25672:25672 --publish 15671:15671 --publish 15672:15672 \
rabbitmq:3.7.15
docker exec -it rabbitmq /bin/bash
rabbitmq-plugins enable rabbitmq_management
#访问地址查看是否安装成功
http://192.168.1.130:15672
账号密码均为guest
设置新⽤户,账号密码均为mall,administrator
Elasticsearch
docker pull elasticsearch:6.4.0
mkdir -p /usr/local/dockerdata/mall-elasticsearch/plugins
mkdir -p /usr/local/dockerdata/mall-elasticsearch/data
chmod 777 /usr/local/dockerdata/mall-elasticsearch/data/
#修改虚拟内存区域⼤⼩,否则会因为过⼩⽽⽆法启动
sysctl -w vm.max_map_count=262144
docker run --restart always -p 9200:9200 -p 9300:9300 --name elasticsearch \
-e "discovery.type=single-node" \
-e "cluster.name=elasticsearch" \
-v /usr/local/dockerdata/mall-elasticsearch/plugins:/usr/share/elasticsearch/plugins \
-v /usr/local/dockerdata/mall-elasticsearch/data:/usr/share/elasticsearch/data \
-d elasticsearch:6.4.0
#访问查看是否成功
http://192.168.1.130:9200/
kibana
docker pull kibana:6.4.0
docker run --restart always --name kibana -p 5601:5601 \
--link elasticsearch:es \
-e "elasticsearch.hosts=http://es:9200" \
-d kibana:6.4.0
#访问查看是否成功
http://192.168.1.130:5601/
Mongodb
docker pull mongo:3.2
docker run --restart always -p 27017:27017 --name mongo \
-v /usr/local/dockerdata/mall-mongodb/db:/data/db \
-d mongo:3.2