2019-01-15 15:53
浏览 393


I am trying to create a docker image with my go application. The application (which was developed on MacOS) depends on confluent-kafka-go which in turn depends on librdkafka-dev which I install in the Docker image like so:

FROM golang:1.1
RUN apt-get update
RUN apt-get -y install librdkafka-dev

VOLUME /workspace
WORKDIR /workspace/src/my/app/folder
ENTRYPOINT ["/bin/sh", "-c"]

I am getting the following error:

my/app/folder/vendor/ ../folder/vendor/ error: #error "confluent-kafka-go requires librdkafka v0.11.5 or later. Install the latest version of librdkafka from the Confluent repositories, see"

As far as I understand the latest version is installed. How can I fix it?

图片转代码服务由CSDN问答提供 功能建议

我正在尝试使用go应用程序创建docker映像。 该应用程序(在MacOS上开发)依赖于 confluent-kafka-go ,而后者又依赖于 librdkafka-dev ,我将其安装在Docker映像中,如下所示:

  FROM golang:1.1 
运行apt-get -y安装librdkafka-dev 
VOLUME / workspace 
WORKDIR / workspace / src / my / app / 文件夹
ENTRYPOINT [“ / bin / sh”,“ -c”] 


我的/应用程序/文件夹/供应商/ / confluentinc /汇合卡夫卡去/卡夫卡 ../文件夹/供应商/ / confluentinc /汇合卡夫卡去/卡夫卡/ 00version.go:44 :2:错误:#error“ confluent-kafka-go需要librdkafka v0.11.5或更高版本。从Confluent存储库中安装最新版本的librdkafka,请参见

据我了解最新版本 已安装。 如何解决?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • dqs66973 2019-01-15 23:06

    I had a similar issue a few weeks ago. IIRC confluent-kafka-go requires a recent version of librdkafka-dev, which simply was not yet released to alpine or others. I was able to find it for ubuntu though, so my solution (which was more involved than I hoped for, but it worked), was to start from clean ubuntu, install librdkafka-dev, install Go version that I want and compile inside docker.

    Here's how it looks:

    FROM ubuntu
    # Install the C lib for kafka
    RUN apt-get update
    RUN apt-get install -y --no-install-recommends apt-utils wget gnupg software-properties-common
    RUN apt-get install -y apt-transport-https ca-certificates
    RUN wget -qO - | apt-key add -
    RUN add-apt-repository "deb [arch=amd64] stable main"
    RUN apt-get update
    RUN apt-get install -y librdkafka-dev
    # Install Go
    RUN add-apt-repository ppa:longsleep/golang-backports
    RUN apt-get update
    RUN apt-get install -y golang-1.11-go
    # build the library
    WORKDIR /go/src/
    COPY *.go ./
    COPY // the rest of your go files. You may copy recursive if you want
    COPY vendor vendor
    RUN GOPATH=/go GOOS=linux /usr/lib/go-1.11/bin/go build -a -o main .
    EXPOSE 8000
    ENTRYPOINT ["./main"]
    点赞 打赏 评论
  • dtqjbbr5283 2019-01-15 16:26

    You can specify a version of package to be installed in apt-get command. e.g

    apt-get install librdkafka-dev=0.11.6~1confluent5.0.1-1

    If that doesn't work then I think the apt sources doesn't have version 0.11.5 of librdkafka. You can add a repository with the right version of librdkafka in /etc/apt/sources.list as described here:

    点赞 打赏 评论

相关推荐 更多相似问题