Docker关注点

 

Overview

xxx

Install example

  1. redis
    • docker run --name myredis -p 6379:6379 redis
    • docker start myredis
    • docker logs -f myredis
    • docker stop myredis
  2. kafka
    • zookeeper
      • docker run --name myzk -p 2181:2181 wurstmeister/zookeeper
    • kafka
      • run kafka image
          docker run --name mykafka -p 9092:9092 \
            --link myzk \
            -e "KAFKA_ADVERTISED_HOST_NAME=localhost" \
            -e "KAFKA_ZOOKEEPER_CONNECT=myzk:2181" \
            wurstmeister/kafka
        
      • valid kafka image
          0. docker exec -it mykafka /bin/bash  #(go to kafka container)
          1. cd opt/kafka_2.12-2.2.1/bin  #(go to kafka inner directory, changed by different kafka version, kafka_xxx-xxx)
          2. list topic
           kafka-topics.sh --zookeeper myzk:2181 --list
          3. create topic
           kafka-topics.sh --create --zookeeper myzk:2181 --replication-factor 1 --partitions 1 --topic myKafkaTopic
           kafka-topics.sh --delete --zookeeper myzk:2181 --topic myKafkaTopic # permanent delete since wurstmeister change the kafka default config
          4. producer push msg into topic
           kafka-console-producer.sh --broker-list localhost:9092 --topic myKafkaTopic
           then input some contents
          5. consumer pull msg from topic
           kafka-console-consumer.sh --bootstrap-server localhost:9092 --from-beginning --topic myKafkaTopic
           then you can see the contents, or you can open another session to see realtime msg
        

      image

      glance

  3. elasticsearch
    • es
      docker run --name myes -p 9200:9200 -p 9300:9300 \
      -e "discovery.type=single-node" \
      -e "cluster.name=my_docker_es_720" \
      -e "node.name=node01" \
      -e "discovery.type=single-node" \
      -e "ES_JAVA_OPTS=-Xms256m -Xmx256m" \
      elasticsearch:7.2.0
      
    • cerebro
      • docker run --rm --name mycere -p 9000:9000 lmenezes/cerebro
        • 在这个命令下,因为docker的网络跟本地网络是不同的,所以此时cere不能直接连localhost:9200,但是可以连ip:9200,ip可以从mac -> system preferences -> network -> Wi-Fi -> address下面查看 image
      • 在同一个网络下发布,但是这样就不能用localhost:9000
      • 使用--link myes,然后地址使用myes:9200
      • 或者直接安装非docker版本。这样就可以直接使用localhost:9200了,因为本地9200已经被映射到docker内部的9200了 image

Reference