Docker:第四章:docker配置阿里云镜像加速并且安装mysql以及安装redis和安装ES

docker配置阿里云镜像加速

  • sudo mkdir -p /etc/docker
  • sudo tee /etc/docker/daemon.json <<-'EOF'
    {
      "registry-mirrors": ["https://jdxszd2m.mirror.aliyuncs.com"]
    }
    EOF
  • sudo systemctl daemon-reload
  • sudo systemctl restart docker

docker安装mysql

  • sudo docker pull mysql:5.7
  • sudo docker images
  • docker run -p 3306:3306 --name mysql -v /mysql/log:/var/log/mysql -v /mysql/conf:/etc/mysql -v /mysql/data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=root -d mysql:5.7
-p 3306:3306  将容器的 3306 端口映射到主机的 3306 端口

--name my-mysql     启动后容器名为 my-mysql  

-v $PWD/conf:/etc/mysql   将主机当前目录下的 conf/ 挂载到容器的 /etc/mysql (conf目录为mysql的配置文件,不挂载也没问题)

-v $PWD/logs:/logs  将主机当前目录下的 logs 目录挂载到容器的 /logs(logs目录为mysql的日志目录,不挂载也没影响)

-v $PWD/data:/var/lib/mysql  将主机当前目录下的data目录挂载到容器的 /var/lib/mysql (data目录为mysql配置的数据文件存放路径,这个还是建议挂载,是存储数据的,容器down掉,还能再次挂载数据。)

-e MYSQL_ROOT_PASSWORD=123456 初始化 root 用户的密码

配置安全组,使用工具连接

docker安装redis

  • docker pull redis
  • mkdir -p /mydata/redis/conf
  • touch /mydata/redis/conf/redis.conf
  • docker run -p 6379:6379 --name redis -v /mydata/redis/data:/data -v /mydata/redis/config/redis.config:/etc/redis/redis.conf  -d redis redis-server /etc/redis/redis.conf

Docker安装jdk

  • docker pull java
  • docker run -d -it --name java java

Docker安装ES

  • docker pull elasticsearch:7.4.2
  • sudo mkdir -p /mydata/myelasticsearch/config
  • sudo mkdir -p /mydata/myelasticsearch/data
  • cd /mydata/myelasticsearch/config
  • echo "http.host: 0.0.0.0">>/mydata/myelasticsearch/config/elasticsearch.yml
  • docker run --name elasticsearch -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" -e ES_JAVA_OPTS="-Xms64m -Xmx128m" -v /mydata/myelasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml -v /mydata/myelasticsearch/data:/usr/share/elasticsearch/data -v /mydata/myelasticsearch/plugins:/usr/share/elasticsearch/plugins -d elasticsearch:7.4.2

Docker安装kibana

  • docker pull kibana:7.4.2
  • http://49.235.111.232:9200/
  • name"8054760198c3"
  • docker inspect 8054760198c3
  • docker run --name kibana -e ELASTICSEARCH_URL=http://172.18.0.5:9200 -p 5601:5601 -d kibana:7.4.2
posted @ 2020-09-22 11:19  javawxid  阅读(259)  评论(0编辑  收藏  举报