zookeeper with kafka docker images - docker

hi i create new zookeeper container and kafka container
i used this command for run zookeeper
docker run -d \
--name zookeeper \
-p 2181:2181 \
jplock/zookeeper
and i used this command for run kafka
docker run -d \
--name kafka \
-p 7203:7203 \
-p 9092:9092 \
-e KAFKA_ADVERTISED_HOST_NAME=127.0.0.1 \
-e ZOOKEEPER_IP=127.0.0.1 \
ches/kafka
and used this command for create new topic
docker run \
--rm ches/kafka kafka-topics.sh \
--create \
--topic senz \
--replication-factor 1 \
--partitions 1 \
--zookeeper 127.0.0.1:2181
but when create kafka new kafka topic i have this error and stop kafka container
[2021-03-03 17:08:35,797] WARN Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect (org.apache.zookeeper.ClientCnxn)
java.net.ConnectException: Connection refused
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)
at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:361)
at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1141)
[2021-03-03 17:08:36,898] WARN Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect (org.apache.zookeeper.ClientCnxn)
java.net.ConnectException: Connection refused
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)
at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:361)
at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1141)
[2021-03-03 17:08:38,006] WARN Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect (org.apache.zookeeper.ClientCnxn)
java.net.ConnectException: Connection refused
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)
at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:361)
at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1141)
Exception in thread "main" org.I0Itec.zkclient.exception.ZkTimeoutException: Unable to connect to zookeeper server '127.0.0.1:2181' with timeout of 30000 ms
at org.I0Itec.zkclient.ZkClient.connect(ZkClient.java:1233)
at org.I0Itec.zkclient.ZkClient.<init>(ZkClient.java:157)
at org.I0Itec.zkclient.ZkClient.<init>(ZkClient.java:131)
at kafka.utils.ZkUtils$.createZkClientAndConnection(ZkUtils.scala:106)
at kafka.utils.ZkUtils$.apply(ZkUtils.scala:88)
at kafka.admin.TopicCommand$.main(TopicCommand.scala:56)
at kafka.admin.TopicCommand.main(TopicCommand.scala)
thanks for help.

the solution in network we must network pointer to zookeeper and kafka the
solution is:
**
1. create new network by docker
**
docker network create kafka-net
2. and now involved your network into zookeeper and kafka like that:
docker run -d\
--name zookeeper \
--network kafka-net
-p 2181:2181 \
jplock/zookeeper
and kafka like this:
docker run -d \
--name kafka \
--network kafka-net
-p 7203:7203 \
-p 9092:9092 \
-e KAFKA_ADVERTISED_HOST_NAME=127.0.0.1 \
-e ZOOKEEPER_IP=zookeeper \
ches/kafka

Related

kafka: Connection to node 1001 could not be established. Broker may not be available

I started zookeeper and kafka container using below commands in CentOS 7.9:
docker run -it -d --net=sup-network --name zookeeper --ip 200.100.0.140 -p 2181:2181 zookeeper:3.7.0
docker run -it --net=sup-network --name kafka -p 9092:9092 \
-e KAFKA_ZOOKEEPER_CONNECT=200.100.0.140:2181 \
-e KAFKA_LISTENERS=PLAINTEXT://0.0.0.0:9092 \
-e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://200.100.0.141:9092 \
-e ALLOW_PLAINTEXT_LISTENER=yes \
-d bitnami/kafka:3.0.0
The 200.100.0.xxx ips are defined in docker swarm.
But kafka consistently gave below logs:
WARN [Controller id=1001, targetBrokerId=1001] Connection to node 1001 (/200.100.0.141:9092)
could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
How to fix it out?
additional info:
I removed -e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://200.100.0.141:9092 \, then kafka didn't give Broker may not be available log info. But why there're so many posts suggest that this line should be added?

Can't log into private registry between instances on Play-with-docker

I am very new to docker so please bear with me. I am following the documentation on https://docs.docker.com/registry/deploying/#running-a-domain-registry
I have spin up 2 nodes on play-with-docker.com for my learning.
On Node1 I am able to set up a private registry successfully using the following command
docker run -d \
-p 5000:5000 \
--restart=always \
--name registry \
-v "$(pwd)"/auth:/auth \
-e "REGISTRY_AUTH=htpasswd" \
-e "REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm" \
-e REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd \
-v "$(pwd)"/certs:/certs \
-e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/domain.crt \
-e REGISTRY_HTTP_TLS_KEY=/certs/domain.key \
registry:2
I was also able to pull and push images from Node1 to the registry. However, when I go on Node2 and try to log in to the registry it gives the following error:
[node2] (local) root#192.168.0.7 ~
$ docker login 192.168.0.8:5000
Username: testuser
Password:
Error response from daemon: Get https://192.168.0.8:5000/v2/: dial tcp 192.168.0.8:5000: connect: connection refused
please let me know what am I missing?
Node2 can't access port 5000 on 192.168.0.8. This looks like a network issue.
Are your nodes in the same network?
Are there firewall rules that might be blocking access to port 5000?
Are you sure 192.168.0.8 is the correct IP address of your Node1 machine?
To test your TCP connection use telnet. For example telnet 192.168.0.8 5000 (assuming 192.168.0.8 is the correct IP address).

cannot connect schema registry kafka

I'm trying to run confluent schema registry via docker image (on Mac os Catalina and Docker version 19.03.12)
docker run --network="host" -e \
SCHEMA_REGISTRY_KAFKASTORE_CONNECTION_URL=localhost:2181 \
-e SCHEMA_REGISTRY_HOST_NAME=localhost \
-e SCHEMA_REGISTRY_LISTENERS=http://0.0.0.0:8081 \
-e SCHEMA_REGISTRY_DEBUG=true confluentinc/cp-schema-registry
I'm running zookeper (3.5.8) and kafka server no the localmachine (no docker). The above picks (3.5.8 client of zookeper). However schema-registry is unable to connect.
[main-SendThread(localhost:2181)]
INFO org.apache.zookeeper.ClientCnxn -
Socket error occurred: localhost/127.0.0.1:2181: Connection refused
[main-SendThread(localhost:2181)]
INFO org.apache.zookeeper.ClientCnxn -
Opening socket connection to server localhost/127.0.0.1:2181.
Will not attempt to authenticate using SASL (unknown error)
I also tried mapping the port, instead of running it in the host network but have the same result
docker run -p 8081:8081 -e \
SCHEMA_REGISTRY_KAFKASTORE_CONNECTION_URL=host.docker.internal:2181 \
-e SCHEMA_REGISTRY_HOST_NAME=localhost \
-e SCHEMA_REGISTRY_LISTENERS=http://0.0.0.0:8081 \
-e SCHEMA_REGISTRY_DEBUG=true confluentinc/cp-schema-registry
Any ideas? Kafka BTW is running happily I can consume and produce messages.

Connection refused with GitLab CI Runner and GitLab CE in Docker

I've got problems trying to run both GitLab CE and the GitLab CI Runner in Docker containers.
This is how I run the GitLab CE container:
docker run --detach \
--name gitlab \
--hostname gitlab.local \
--publish 80:80 \
--restart always \
--env GITLAB_OMNIBUS_CONFIG="external_url 'http://gitlab.local/';" \
--volume ~/volumes/gitlab/config:/etc/gitlab \
--volume ~/volumes/gitlab/logs:/var/log/gitlab \
--volume ~/volumes/gitlab/data:/var/opt/gitlab \
gitlab/gitlab-ce
Then I can connect to GitLab without problems on the host both through the locally bound interface — i.e. http://localhost — and the container IP — i.e. http://gitlab.local after adding e.g. 172.17.0.2 gitlab gitlab.local on my hosts file).
The problems arise when I try to register a GitLab CI Runner container, through:
docker run --rm --tty --interactive \
--name gitlab-runner-register \
--add-host "gitlab.local:172.17.0.2" \
--link=gitlab \
--volume ~/volumes/gitlab-runner:/etc/gitlab-runner \
gitlab/gitlab-runner \
register \
--non-interactive \
--executor "docker" \
--docker-image alpine:3 \
--url "http://gitlab.local/" \
--registration-token "XXXXXXXXXXXX" \
--description "docker-runner" \
--tag-list "docker" \
--run-untagged \
--locked="false"
The errors I get are:
ERROR: Registering runner... failed runner=XXXXXX status=couldn't execute POST against http://gitlab.local/api/v4/runners: Post http://gitlab.local/api/v4/runners: dial tcp 172.17.0.2:80: getsockopt: connection refused
PANIC: Failed to register this runner. Perhaps you are having network problems
Some help? Thanks in advance!
UPDATE: I've also tried to link a BusyBox to the gitlab container. Pinging it works like a charm, but wgetting it gives Connection refused:
$ docker run --rm --link=gitlab busybox ping -c 1 gitlab
PING gitlab (172.17.0.2): 56 data bytes
64 bytes from 172.17.0.2: seq=0 ttl=64 time=0.124 ms
--- gitlab ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 0.124/0.124/0.124 ms
$ docker run --rm --link=gitlab busybox wget http://gitlab
Connecting to gitlab (172.17.0.2:80)
wget: can't connect to remote host (172.17.0.2): Connection refused
So networking is working fine and probably the "issue" is more related to the binding. As demonstration of this, I've tried to run a python http server in the gitlab container in order to retry the wget command and... it works:
$ docker run --rm --link=gitlab busybox wget http://gitlab:8000
Connecting to gitlab:8000 (172.17.0.2:8000)
index.html 100% |********************************| 1065 0:00:00 ETA

Connection refused when trying to run Kong API Gateway using a docker container

I am trying to run Kong API Gateway using a docker container. I followed the instructions on hub.docker.com/_/kong/, started Cassandra database and Kong.
I have Cassandra running using the below command:
docker run -d --name kong-database \
-p 9042:9042 \
cassandra:3
and Kong running using the below command:
docker run -d --name kong \
--link kong-database:kong-database \
-e "KONG_DATABASE=cassandra" \
-e "KONG_CASSANDRA_CONTACT_POINTS=kong-database" \
-p 8000:8000 \
-p 8443:8443 \
-p 8001:8001 \
-p 7946:7946 \
-p 7946:7946/udp \
kong:latest
Both containers are running. (I don't have enough reputations to embed pictures here right now so please see a screenshot here:
my container list)
However when I do:
$ curl http://127.0.0.1:8001
I got this:
curl: (7) Failed to connect to 127.0.0.1 port 8001: Connection refused
Can anyone let me know what is the possible reason?
Ok, check the logs of the kong container to find any errors if there are any(docker logs kong).
If there aren't any errors, please check whether there is any active process running on the port or not(sudo netstat -anp | grep 8001). That will help us know whether the docker-container port 8001 was properly binded to server port 8001 and also the ip on which the port is running.
If there is process running on that port, then it might be an issue of running docker on bridge network which is not able to bind the port with localhost. try re-running the container with network host(--net host). Then it should work fine.

Resources