kafka-docker
kafka-docker copied to clipboard
Can't run kafka container - sed: unmatched '@'
Hi,
I'm using a simple docker-compose configuration:
version: "3.4"
services:
zookeeper:
image: zookeeper
ports:
- "2181:2181"
kafka:
image: wurstmeister/kafka:2.12-2.5.0
ports:
- "9092:9092"
depends_on:
- zookeeper
environment:
KAFKA_ADVERTISED_HOST_NAME: 172.17.0.1
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
KAFKA_MESSAGE_MAX_BYTES: 104858800
volumes:
- /var/run/docker.sock:/var/run/docker.sock
kafka-web-gui:
image: tchiotludo/akhq
ports:
- "8081:8080"
environment:
AKHQ_CONFIGURATION: |
akhq:
connections:
docker-kafka-server:
properties:
bootstrap.servers: "kafka:9092"
My stack is running without any problem in the first execution. But, when I try to run the kafka container again, I get the following error:
kafka_1 | [Configuring] 'advertised.port' in '/opt/kafka/config/server.properties' kafka_1 | sed: unmatched '@' kafka-deployment_kafka_1 exited with code 1
I use ubuntu 20.04 Docker version 20.10.6, build 370c289 docker-compose version 1.26.0, build d4451659
Hello,
i'm experiencing the same error on
Linux version 5.4.0-72-generic (buildd@lcy01-amd64-019) (gcc version 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04)) #80-Ubuntu SMP Mon Apr 12 17:35:00 UTC 2021
Client: Docker Engine - Community Version: 20.10.6 API version: 1.41 Go version: go1.13.15 Git commit: 370c289 Built: Fri Apr 9 22:47:17 2021 OS/Arch: linux/amd64 Context: default Experimental: true
docker-compose version 1.27.4, build 40524192
With the Dockerfile
FROM openjdk:8u212-jre-alpine
ARG kafka_version=2.4.0
ARG scala_version=2.12
ARG glibc_version=2.30-r0
ARG vcs_ref=unspecified
ARG build_date=unspecified
LABEL org.label-schema.name="kafka" \
org.label-schema.description="Apache Kafka" \
org.label-schema.build-date="${build_date}" \
org.label-schema.vcs-url="https://github.com/wurstmeister/kafka-docker" \
org.label-schema.vcs-ref="${vcs_ref}" \
org.label-schema.version="${scala_version}_${kafka_version}" \
org.label-schema.schema-version="1.0" \
maintainer="wurstmeister"
ENV KAFKA_VERSION=$kafka_version \
SCALA_VERSION=$scala_version \
KAFKA_HOME=/opt/kafka \
GLIBC_VERSION=$glibc_version
ENV PATH=${PATH}:${KAFKA_HOME}/bin
COPY download-kafka.sh start-kafka.sh broker-list.sh create-topics.sh versions.sh /tmp/
RUN apk add --no-cache bash curl jq docker \
&& chmod a+x /tmp/*.sh \
&& mv /tmp/start-kafka.sh /tmp/broker-list.sh /tmp/create-topics.sh /tmp/versions.sh /usr/bin \
&& sync && /tmp/download-kafka.sh \
&& tar xfz /tmp/kafka_${SCALA_VERSION}-${KAFKA_VERSION}.tgz -C /opt \
&& rm /tmp/kafka_${SCALA_VERSION}-${KAFKA_VERSION}.tgz \
&& ln -s /opt/kafka_${SCALA_VERSION}-${KAFKA_VERSION} ${KAFKA_HOME} \
&& rm /tmp/* \
&& wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VERSION}/glibc-${GLIBC_VERSION}.apk \
&& apk add --no-cache --allow-untrusted glibc-${GLIBC_VERSION}.apk \
&& rm glibc-${GLIBC_VERSION}.apk
COPY overrides /opt/overrides
VOLUME ["/kafka"]
# Use "exec" form so that it runs as PID 1 (useful for graceful shutdown)
CMD ["start-kafka.sh"]
Could this be related to some recent changes in Alpine?
+1 get the same error messages
Cuz the error shows something about advertised.port
. So I specify the advertised port = 9092. It's working well.
If the consumer/producer can't receive/send data, remove the zookeeper and kafka container and compose up it again.
...
environment:
- KAFKA_ADVERTISED_HOST_NAME=kafka
- KAFKA_ADVERTISED_PORT=9092
- ...
i had this error as well. i solved it by running docker-compose down
before re-running docker-compose up
again
+1 get the same error messages. im running a cluster, i tried to stop one node and start again, it failed with 'sed: unmatched '@' docker stop kafka_node_x, successfully docker start kafka_node_x, failed
Excluding KAFKA_JMX_OPTS from broker config [Configuring] 'advertised.port' in '/opt/kafka/config/server.properties' sed: unmatched '@'
change
docker stop kafka_node_x, successfully
to
docker rm -f kafka_node_x
and problem will be resolved
+1. If I create a topic, whenever I restart docker containers like zookeeper and kakfa, docker stuck with error like below waiting for kafka to be ready [Configuring] 'advertised.port' in '/opt/kafka/config/server.properties' sed: unmatched '@'
@wurstmeister is there a possible fix coming?
@wurstmeister is there a possible fix coming?
This package seems to be working as intended. Try tearing down the container and re-composing it.
I suspect that the following might also be related to the above - the end of the /opt/kafka/config/server.properties
file reads:
port=9092
advertised.host.name=127.0.0.1
advertised.port=9092
9092
That last 9092
looks like it's there from a missing keyname.
bash-5.1# cat start-kafka.sh
...
if [[ -z "$KAFKA_ADVERTISED_PORT" && \
-z "$KAFKA_LISTENERS" && \
-z "$KAFKA_ADVERTISED_LISTENERS" && \
-S /var/run/docker.sock ]]; then
KAFKA_ADVERTISED_PORT=$(docker port "$(hostname)" $KAFKA_PORT | sed -r 's/.*:(.*)/\1/g')
export KAFKA_ADVERTISED_PORT
fi
...
in docker 20.10.6 ,if docker run with '-p 9092:9092'
bash-5.1# echo KAFKA_ADVERTISED_PORT=$(docker port "$(hostname)" $KAFKA_PORT | sed -r 's/.*:(.*)/\1/g')
KAFKA_ADVERTISED_PORT=9092 9092
I suspect that the following might also be related to the above - the end of the
/opt/kafka/config/server.properties
file reads:port=9092 advertised.host.name=127.0.0.1 advertised.port=9092 9092
That last
9092
looks like it's there from a missing keyname.
I have this issue as well. Every time I stop a docker container and restart I get this error. I have to remove the image before I'm able to start again.
I have this issue as well. Every time I stop a docker container and restart I get this error. I have to remove the image before I'm able to start again.
this is because you are not tearing down the container. i don't understand why after all of these comments in this thread there are still issues. run docker-compose down to tear it down properly. It seems that many users are still new to docker.....
I have this issue as well. Every time I stop a docker container and restart I get this error. I have to remove the image before I'm able to start again.
this is because you are not tearing down the container. i don't understand why after all of these comments in this thread there are still issues. run docker-compose down to tear it down properly. It seems that many users are still new to docker.....
it does't work
To everybody here, just follow this in this thread. I got the same issue just like you guys, and that resolved my issue.
I've contributed a PR to handle this issue. #674
Personal story -- I've resolved this by running docker-compose down
, after this -- docker-compose -f ... up
works.