kafka-docker
kafka-docker copied to clipboard
Failed to map both directory and file
I used docker compose to deploy Kafka, started SASL, and failed to map the JAAS file into the container.
docker-compose:
version: '3.5'
services:
zookeeper:
image: wurstmeister/zookeeper:3.4.6 ## 镜像
container_name: zookeeper
ports:
- "2181:2181" ## 对外暴露的端口号
volumes:
#- type: bind
# source: ./zookeeper/conf/zk_server_jaas.conf
# target: /opt/zookeeper-3.4.6/conf/zk_server_jaas.conf
- ./zookeeper/conf/zk_server_jaas.conf:/opt/zookeeper-3.4.6/conf/zk_server_jaas.conf
- ./zookeeper/data:/opt/zookeeper-3.4.6/data
- ./zookeeper/datalog:/opt/zookeeper-3.4.6/datalog
environment:
ZOOKEEPER_CLIENT_PORT: 2181
ZOOKEEPER_TICK_TIME: 2000
ZOOKEEPER_MAXCLIENTCNXNS: 0
ZOOKEEPER_AUTHPROVIDER.1: org.apache.zookeeper.server.auth.SASLAuthenticationProvider
ZOOKEEPER_REQUIRECLIENTAUTHSCHEME: sasl
ZOOKEEPER_JAASLOGINRENEW: 3600000
ZOOKEEPER_SERVER_JVMFLAGS: -Djava.security.auth.login.config=/opt/zookeeper-3.4.6/conf/zk_server_jaas.conf
restart: always
kafka:
image: wurstmeister/kafka:2.12-2.5.0 ## 镜像
container_name: kafka
volumes:
- type: bind
source: ./kafka/sasl
target: /opt/kafka_2.12-2.5.0/sasl
- /etc/localtime:/etc/localtime ## 挂载位置(kafka镜像和宿主机器之间时间保持一直)
ports:
- "9092:9092"
volumes:
- ./kafka/data:/kafka
environment:
KAFKA_BROKER_ID: 1
KAFKA_ADVERTISED_HOST_NAME: 192.168.6.169 ## 修改为宿主机IP
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 ## 卡夫卡运行是基于zookeeper的
KAFKA_LISTENERS: SASL_PLAINTEXT://192.168.6.169:9092
KAFKA_ADVERTISED_LISTENERS: SASL_PLAINTEXT://192.168.6.169:9092
KAFKA_SECURITY_INTER_BROKER_PROTOCOL: SASL_PLAINTEXT
KAFKA_SASL_MECHANISM_INTER_BROKER_PROTOCOL: PLAIN
KAFKA_SASL_ENABLED_MECHANISMS: PLAIN
KAFKA_AUTHORIZER_CLASS_NAME: kafka.security.auth.SimpleAclAuthorizer
KAFKA_OPTS: -Djava.security.auth.login.config=/opt/kafka_2.12-2.5.0/config/kafka_server_jaas.conf
KAFKA_SUPER_USERS: User:admin
KAFKA_ADVERTISED_PORT: 9092
KAFKA_LOG_RETENTION_HOURS: 120
KAFKA_MESSAGE_MAX_BYTES: 10000000
KAFKA_REPLICA_FETCH_MAX_BYTES: 10000000
KAFKA_GROUP_MAX_SESSION_TIMEOUT_MS: 60000
KAFKA_NUM_PARTITIONS: 1
KAFKA_DELETE_RETENTION_MS: 1000
KAFKA_SOCKET_REQUEST_MAX_BYTES: 1048576000
depends_on:
- zookeeper
#privileged: true