Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error running the bridge as Docker container #452

Open
ppatierno opened this issue Jul 10, 2020 · 2 comments
Open

Error running the bridge as Docker container #452

ppatierno opened this issue Jul 10, 2020 · 2 comments

Comments

@ppatierno
Copy link
Member

Trying to run the bridge just as Docker container outside of Kubernetes gets the following error:

docker run -it strimzi/kafka-bridge:0.17.0
[2020-07-10 08:23:37,145] INFO  <Application :64> [main        ] Strimzi Kafka Bridge 0.17.0 is starting
[2020-07-10 08:23:37,271] ERROR <Application :152> [main        ] Error starting the bridge
org.apache.commons.cli.MissingOptionException: Missing required option: config-file
	at org.apache.commons.cli.DefaultParser.checkRequiredOptions(DefaultParser.java:199) ~[commons-cli-1.4.jar:1.4]
	at org.apache.commons.cli.DefaultParser.parse(DefaultParser.java:130) ~[commons-cli-1.4.jar:1.4]
	at org.apache.commons.cli.DefaultParser.parse(DefaultParser.java:76) ~[commons-cli-1.4.jar:1.4]
	at org.apache.commons.cli.DefaultParser.parse(DefaultParser.java:60) ~[commons-cli-1.4.jar:1.4]
	at io.strimzi.kafka.bridge.Application.main(Application.java:80) [kafka-bridge-0.17.0.jar:0.17.0]

Of course, that's because it needs the --config-file parameter with the configuration properties file.
Anyway even providing it, gets the following error:

docker run -it strimzi/kafka-bridge:0.17.0 --config-file=config/application.properties
docker: Error response from daemon: OCI runtime create failed: container_linux.go:349: starting container process caused "exec: \"--config-file=config/application.properties\": stat --config-file=config/application.properties: no such file or directory": unknown.
ERRO[0000] error waiting for container: context canceled

Even in this case the problem seems to be clear. We are using CMD in the Docker file, instead of ENTRYPOINT so the argument passed on the docker run is got as the command to run and not as a parameter for the entrypoint.
I already built a custom image using ENTRYPOINT instead of CMD and the above command works fine allowing the bridge to start as a Docker container.

This change should not have any impact on how the Strimzi operator deploys the bridge because it's going anyway to override the Kubernetes command with the corresponding Docker script (Kubernetes command is the counterpart of Docker ENTRYPOINT while Kubernetes args should be counterpart of Docker CMD).

I am ready to open a PR for this change, any more thoughts or considerations? @strimzi/maintainers

@hth1995
Copy link

hth1995 commented Dec 4, 2020

I got the same error with you. Have any update?

@head1328
Copy link

head1328 commented Jan 21, 2021

It is possible to run the bridge with: docker run -it --rm --entrypoint=/opt/strimzi/bin/kafka_bridge_run.sh strimzi/kafka-bridge:0.19.0 --config-file=config/application.properties

Unfortunately it's not possible to configure the bridge via environment variables (e.g. JAVA_OPTS). So I decided to mount a custom application.properties with the correct kafka.bootstrap.server.

This is my docker-compose.yml (...from the Quarkus docs)

  version: '3.5'

  services:
    zookeeper:
      image: strimzi/kafka:0.19.0-kafka-2.5.0
      command:
        - sh
        - -c
        - bin/zookeeper-server-start.sh config/zookeeper.properties
      ports:
        - 2181:2181
      environment:
        LOG_DIR: /tmp/logs
    
    kafka:
      image: strimzi/kafka:0.19.0-kafka-2.5.0
      command:
        - sh
        - -c
        - bin/kafka-server-start.sh config/server.properties 
          --override listeners=$${KAFKA_LISTENERS} 
          --override advertised.listeners=$${KAFKA_ADVERTISED_LISTENERS} 
          --override zookeeper.connect=$${KAFKA_ZOOKEEPER_CONNECT} 
          --override num.partitions=$${KAFKA_NUM_PARTITIONS}
      depends_on:
        - zookeeper
      ports:
        - 9092:9092
      environment:
        LOG_DIR: /tmp/logs
        KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092
        KAFKA_LISTENERS: PLAINTEXT://0.0.0.0:9092
        KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
        KAFKA_NUM_PARTITIONS: 3
    
    # my additional custom services
    kafkacat:
      image: debezium/tooling:1.1
      entrypoint: /usr/bin/kafkacat
      command: --help
      depends_on:
        - kafka
    
    kafka-bridge:
      image: strimzi/kafka-bridge:0.19.0
      entrypoint: /opt/strimzi/bin/kafka_bridge_run.sh
      command: --config-file=config/application.properties
      volumes:
        - ./kafka-bridge/application.properties:/opt/strimzi/config/application.properties
      depends_on:
        - kafka
      ports:
        - 9080:8080

And my ./kafka-bridge/application.properties file:

    #Bridge related settings
    bridge.id=my-bridge
    # uncomment the following line to enable Jaeger tracing, check the documentation how to configure the tracer
    #bridge.tracing=jaeger

    #Apache Kafka common
    kafka.bootstrap.servers=kafka:9092

    #Apache Kafka producer
    kafka.producer.acks=1

    #Apache Kafka consumer
    kafka.consumer.auto.offset.reset=earliest

    #AMQP related settings
    amqp.enabled=false
    amqp.flowCredit=100
    amqp.mode=SERVER
    amqp.host=0.0.0.0
    amqp.port=5672
    amqp.certDir=
    amqp.messageConverter=io.strimzi.kafka.bridge.amqp.converter.AmqpDefaultMessageConverter

    #HTTP related settings
    http.enabled=true
    http.host=0.0.0.0
    http.port=8080
    #Enable CORS
    http.cors.enabled=false
    http.cors.allowedOrigins=*
    http.cors.allowedMethods=GET,POST,PUT,DELETE,OPTIONS,PATCH

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants