{"id":9372,"date":"2022-10-10T20:42:04","date_gmt":"2022-10-10T20:42:04","guid":{"rendered":"http:\/\/putridparrot.com\/blog\/?p=9372"},"modified":"2022-10-11T08:28:33","modified_gmt":"2022-10-11T08:28:33","slug":"running-kafka-within-docker","status":"publish","type":"post","link":"https:\/\/putridparrot.com\/blog\/running-kafka-within-docker\/","title":{"rendered":"Running Kafka within Docker"},"content":{"rendered":"<p><em>Note: This post was written a while back but sat in draft. I&#8217;ve published this now, but I&#8217;m not sure it&#8217;s relevant to the latest versions etc. so please bear this in mind.<\/em><\/p>\n<p><strong>Kafka<\/strong><\/p>\n<p><a href=\"https:\/\/kafka.apache.org\/\" rel=\"noopener\" target=\"_blank\">Kafka<\/a> is an event streaming service.<\/p>\n<p>Let&#8217;s pull the image<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\ndocker pull confluentinc\/cp-kafka\r\n<\/pre>\n<p>The docker image of Kakfa requires Zookeeper.<\/p>\n<p><strong>Putting it all together<\/strong><\/p>\n<p>Create yourself a docker-compose.yml (this one below is taken from <a href=\"https:\/\/www.baeldung.com\/ops\/kafka-docker-setup\" rel=\"noopener\" target=\"_blank\">Guide to Setting Up Apache<\/a>.<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nversion: '2'\r\nservices:\r\n  zookeeper:\r\n    image: confluentinc\/cp-zookeeper:latest\r\n    environment:\r\n      ZOOKEEPER_CLIENT_PORT: 2181\r\n      ZOOKEEPER_TICK_TIME: 2000\r\n    ports:\r\n      - 22181:2181\r\n  \r\n  kafka:\r\n    image: confluentinc\/cp-kafka:latest\r\n    depends_on:\r\n      - zookeeper\r\n    ports:\r\n      - 29092:29092\r\n    environment:\r\n      KAFKA_BROKER_ID: 1\r\n      KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181\r\n      KAFKA_ADVERTISED_LISTENERS: PLAINTEXT:\/\/kafka:9092,PLAINTEXT_HOST:\/\/localhost:29092\r\n      KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT\r\n      KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT\r\n      KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1\r\n<\/pre>\n<p>From your server, you can now connect to Kafka using the docker name (hence replace the docker-name with the name you gave or docker gave to your Kafka instance)<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\ndocker exec -it docker-name \/bin\/sh\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Note: This post was written a while back but sat in draft. I&#8217;ve published this now, but I&#8217;m not sure it&#8217;s relevant to the latest versions etc. so please bear this in mind. Kafka Kafka is an event streaming service. Let&#8217;s pull the image docker pull confluentinc\/cp-kafka The docker image of Kakfa requires Zookeeper. Putting [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[337],"tags":[],"class_list":["post-9372","post","type-post","status-publish","format-standard","hentry","category-kafka"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/9372","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/comments?post=9372"}],"version-history":[{"count":5,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/9372\/revisions"}],"predecessor-version":[{"id":9571,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/9372\/revisions\/9571"}],"wp:attachment":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/media?parent=9372"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/categories?post=9372"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/tags?post=9372"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}