1. 首先安装Vagrant,和VirtualBox, 
  1. Vagrant下载地址:https://www.vagrantup.com/VirtualBox下载地址:https://www.virtualbox.org/
  2. wind+r ---cmd    输入vagrant看有没有装上
  1. 然后使用vagrant init centos/7下载
  2. 使用vagrant up 下载镜像
  3. 下载完镜像之后每天的启动就是vagrant ssh
  4. 切换root用户:切换root用户:
  5. 使用密码登录虚拟机: 使用密码登录虚拟机将PasswordAuthentication no改为yes
  6. service sshd restart 重启客户端
  7. 卸载已有的docker :其中 \ 是代表换行  
1. sudo yum remove docker \
		docker-client \
		docker-client-latest \
		docker-common \
		docker-latest \
		docker-latest-logrotate \
		docker-logrotate \
		docker-engine
  1. 安装需要的软件包, yum-util 提供yum-config-manager功能,另外两个是devicemapper驱动依赖的:
1. sudo yum install -y yum-utils \
device-mapper-persistent-data \
lvm2
  1. 设置yum源:
sudo yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
  1. 进行docker的安装 : sudo yum install docker-ce docker-ce-cli containerd.io
  2. 启动docker : sudo systemctl start docker
  3. 查看docker版本:docker -v
  4. 开机自启docker : sudo systemctl enable docker
  5. 删除所有docker中没有运行的container: docker container prune
  6. 配置阿里云镜像加速:
1. sudo mkdir -p /etc/docker    
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors":["https://92m9ar63.mirror.aliyuncs.com"]
}
EOF
  1. 重启docker后台线程:sudo systemctl daemon-reload
  2. 重启docker服务:sudo systemctl restart docker
  3. 使用docker下载mysql 5.7: sudo docker pull mysql:5.7
  4. 查看docker正在运行中的容器:docker ps
  5. 创建实例并且启动mysql:其中-v是将容器内的文件和宿主机文件进行挂载,这样修改i配置的时候就不需要再进入到重启中修改配置
1. docker run -p 3306:3306 --name mysql \
-v /mydata/mysql/log:/var/log/mysql \
-v /mydata/mysql/data:/var/lib/mysql \
-v /mydata/mysql/conf:/etc/mysql \
-e MYSQL_ROOT_PASSWORD=root \
-d mysql:5.7
  1. docker进入msql内部容器:docker exec -it mysql /bin/bash
  2. MySQL配置:
1. [client]
default-character-set=utf8
[mysql]
default-character-set=utf8
[mysqld]
init_connect='SET collation_connection = utf8_unicode_ci'
init_connect='SET NAMES utf8'
character-set-server=utf8
collation-server=utf8_unicode_ci
skip-character-set-client-handshake
skip-name-resolve
  1. docker重启mysql : docker重启mysql
  2. docker下载redis(下载最新) : docker pull redis
  3. Docker安装redis:
  1. 创建配置文件夹 : mkdir -p /mydata/redis/conf
  2. 创建配置文件 : touch /mydata/redis/conf/redis.conf
  3. 使用docker命令安装并且挂在到宿主机上面 : docker run -p 6379:6379 --name redis -v /mydata/redis/data:/data \
    -v /mydata/redis/conf/redis.conf:/etc/redis/redis.conf \
    -d redis redis-server /etc/redis/redis.conf
  4. 进入到docker的redis : docker exec -it redis redis-cli
27. yum remove docker \
                   docker-client \
                   docker-client-latest \
                 docker-common \
                   docker-latest \
                   docker-latest-logrotate \
                 docker-logrotate \
                  docker-selinux \
                   docker-engine-selinux \
                 docker-engine
  1.  
  2. docker pull elasticsearch:7.4.2
  3. docker pull kibana:7.4.2
  4. free -m
  5. mkdir -p /mydata/elasticsearch/config
  6. mkdir -p /mydata/elasticsearch/data
  7. echo "http.host:0.0.0.0">>/mydata/elasticsearch/config/elasticsearch.yml
  8. 运行docker中的elasticSearch并且挂载到宿主机 :
1. docker run --name elasticsearch -p 9200:9200 -p 9300:9300 \
-e "discovery.type=single-node" \
-e ES_JAVA_OPTS="-Xms64m -Xmx128m" \
-v /mydata/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/conf/elasticsearch.yml \
-v /mydata/elasticsearch/data:/usr/share/elasticsearch/data \
-v /mydata/elasticsearch/plugins:/usr/share/elasticsearch/plugins \
-d elasticsearch:7.4.2
  1. chmod -R 777 /mydata/elasticsearch/
  2. docker ps -a
  3. docker start "CONTAINER ID"数量进行容器的启动
  4. --------------------------------docker安装Kibana---------------------------------------------
  5. 第30步已经拉取了Kibana镜像z这里只需要运行挂载就可以:docker run --name kibana -e ELASTICSEARCH_HOSTS=http://192.168.56.10:9200 -p 5601:5601 \
    -d kibana:7.4.2
  6. ------------------------------Docker安装nginx-------------------------------------------------
  7. 拉取nginx镜像:docker pull nginx:latest
  8. 查看镜像:docker images
  9. 运行nginx镜像:docker run --name nginxtest -p 9091:80 -d 8c
  10. 创建需要挂载的文件:
1.  mkdir -p /server/nginx/html 
 mkdir -p /server/nginx/logs
 mkdir -p /server/nginx/conf
  1. 将容器里面的配置复制到宿主机文件进行挂载:
docker cp d61e3f6b74b3:/etc/nginx/nginx.conf /server/nginx/conf
  1. (其中 d61e3f6b74b3是容器的id,后面的容器内的文件路径以及要复制到宿主机的文件路径)
  2. 进行容器挂载 :
46. docker run -d -p 80:80 --name nginx  -v /server/nginx/html:/usr/share/nginx/html -v /server/nginx/conf/nginx.conf:/etc/nginx/nginx.conf -v /server/nginx/conf.d:/etc/nginx/conf.d -v /server/nginx/logs:/var/log/nginx nginx