My task is to run Kafka connectors in docker containers, when I tried run connectors on my host all worked fine, but in container it fails. I know that there are a lot similar questions( I am new in Kafka and Redis and really can not find solution). I tried a lot solutuons, the algorithm from this answer Connecting a Redis container with another container (Docker) seems really amazing, but in doesn't work for me and I can't understand why.
In Docker app it gives me stack trace as:
ERROR WorkerSinkTask{id=kafka-connect-redis-0} Task threw an uncaught and unrecoverable exception (org.apache.kafka.connect.runtime.WorkerTask:186)io.lettuce.core.RedisConnectionException: Unable to connect to redis-master:6379at io.lettuce.core.RedisConnectionException.create(RedisConnectionException.java:78)Caused by: io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection refused: redis-master/172.22.0.3:6379Caused by: java.net.ConnectException: Connection refusedat sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
My Redis config:
replicaof redis-master 6379# bind 0.0.0.0protected-mode no
My connector properties file
name=kafka-connect-redistopics=botstasks.max=1connector.class=com.github.jcustenborder.kafka.connect.redis.RedisSinkConnectorkey.converter=org.apache.kafka.connect.storage.StringConverterkey.converter.schemas.enable=falsevalue.converter=org.apache.kafka.connect.storage.StringConverter#offset.storage.file.filename=/tmp/connection/redis/connect.offsetsredis.hosts=redis-master,redis-slave-1,redis-slave-2use.record.key=true
My docker compose:
redis-master: image: redis container_name: redis-m# ports:# - 6379:6379 volumes: - ./clear-redis.sh:/bin/clear-redis.sh command: bash -c "chmod +x /bin/clear-redis.sh && bash /bin/clear-redis.sh" redis-slave-1: image: redis container_name: redis-s-1# ports:# - 7000:6379 volumes: - ./config/redis:/usr/local/etc/redis/ command: redis-server /usr/local/etc/redis/redis.conf redis-slave-2: image: redis container_name: redis-s-2# ports:# - 7001:6379 volumes: - ./config/redis:/usr/local/etc/redis/ command: redis-server /usr/local/etc/redis/redis.conf kafka-connect-redis: image: confluentinc/cp-kafka-connect:5.5.1 container_name: connect-redis hostname: kafka-connect-redis ports: - 8086:8086 volumes: - ./connection/connectors/kafka-connect-redis/lib/:/etc/kafka-connect/jars/ - ./connection/connectors/kafka-connect-redis/redis-sink.properties:/usr/share/redis-sink.properties - ./connection/connect-standalone-2.properties:/etc/connect-standalone-2.properties - ./connection/run-redis.sh:/bin/run-redis.sh depends_on: - zoo - kafka1 - kafka2 - kafka3 - redis-master - redis-slave-1 - redis-slave-2 command: bash -c "chmod +x /bin/run-redis.sh && ./bin/run-redis.sh"