Mysql
sudo docker run -p 3306:3306 --name mysql -v /Users/didi/docker/mysql/conf:/etc/mysql/conf.d -v /Users/didi/docker/mysql/logs:/logs -v /Users/didi/docker/mysql/data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=123456 -d mysql:5.6
Kafka
安装Zookeeper
docker run -d --name=cZookeeper -p 172.22.25.124:2181:2181 \
-v ~/etc/timezone:/etc/localtime:ro \
zookeeper:latest
安装kafka
docker run -d --name=cKafka -p 172.22.25.124:9092:9092 \
--link cZookeeper \
--env KAFKA_ZOOKEEPER_CONNECT=cZookeeper:2181 \
--env KAFKA_ADVERTISED_HOST_NAME=172.22.25.124 \
--env KAFKA_ADVERTISED_PORT=9092 \
-v ~/etc/timezone:/etc/localtime:ro \
wurstmeister/kafka:latest
注意:
x.x.x.x换为宿主机的ip
~/etc/timezone为自建文件夹,为了解决mac下文件夹权限问题,https://github.com/docker/for-mac/issues/2396#issuecomment-370033847
测试
docker exec -it cKafka /opt/kafka/bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test
docker exec -it cKafka /opt/kafka/bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic credit_feature_topic --from-beginning
网友评论