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: "Service 'kafka' failed to build" during compose-up #529

Open
sabond9 opened this issue Aug 31, 2019 · 8 comments
Open

Error: "Service 'kafka' failed to build" during compose-up #529

sabond9 opened this issue Aug 31, 2019 · 8 comments
Labels

Comments

@sabond9
Copy link

sabond9 commented Aug 31, 2019

I called command docker-compose up -d to run zookeeper and kafka but I got error:

ERROR: Service 'kafka' failed to build: The command '/bin/sh -c 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' returned a non-zero code: 2

My docker-compose.yml file looks:

version: '2'
services:
  zookeeper:
    image: wurstmeister/zookeeper
    ports:
      - "2181:2181"
  kafka:
    build: .
    ports:
      - "9092"
    environment:
      KAFKA_ADVERTISED_HOST_NAME: kafka
      KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock

I'm using docker on Windows 10. How can I fix it?

@sscaling
Copy link
Collaborator

sscaling commented Sep 1, 2019

You have only included the part of the log that says a command in the Dockerfile failed. I would suggest including the previous lines that show the output of the RUN command up until it failed.

If you are not customising the image, then I would suggest using a prebuilt image from dockerhub, e.g.

    # build: .
    image: wurstmeister/kafka

If you're still having issues, there are reported problems mounting the docker unix domain socket, this is covered in the FAQ

There are reports that dos2unix can fix some issues - #195, and a few different fixes in this issue - #319

General windows issues are labelled with the windows label.

@sabond9
Copy link
Author

sabond9 commented Sep 1, 2019

I have issues running containers on Windows. There is the full log:

PS C:\Users\admin> cd C:\kafka-docker
PS C:\kafka-docker> docker-compose up -d
Building kafka
Step 1/14 : FROM openjdk:8u212-jre-alpine
 ---> f7a292bbb70c
Step 2/14 : ARG kafka_version=2.3.0
 ---> Running in def274f71a04
Removing intermediate container def274f71a04
 ---> 876f55f4f002
Step 3/14 : ARG scala_version=2.12
 ---> Running in 9464e9109b8d
Removing intermediate container 9464e9109b8d
 ---> 90fcfc442f26
Step 4/14 : ARG glibc_version=2.29-r0
 ---> Running in 1bb81a4d2645
Removing intermediate container 1bb81a4d2645
 ---> c5f598c4fb05
Step 5/14 : ARG vcs_ref=unspecified
 ---> Running in 03a860bbbaaf
Removing intermediate container 03a860bbbaaf
 ---> 667c8570cf6d
Step 6/14 : ARG build_date=unspecified
 ---> Running in a6afbda75c17
Removing intermediate container a6afbda75c17
 ---> adaa38eca1ee
Step 7/14 : 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"
 ---> Running in ca7dec807759
Removing intermediate container ca7dec807759
 ---> 23a18bc406c3
Step 8/14 : ENV KAFKA_VERSION=$kafka_version     SCALA_VERSION=$scala_version     KAFKA_HOME=/opt/kafka     GLIBC_VERSION=$glibc_version
 ---> Running in 5ce8cd0b1751
Removing intermediate container 5ce8cd0b1751
 ---> 996ec61f38f9
Step 9/14 : ENV PATH=${PATH}:${KAFKA_HOME}/bin
 ---> Running in 303c2c503660
Removing intermediate container 303c2c503660
 ---> 92056621296a
Step 10/14 : COPY download-kafka.sh start-kafka.sh broker-list.sh create-topics.sh versions.sh /tmp/
 ---> f656b5237fa9
Step 11/14 : 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
 ---> Running in 0da87a27a5fa
fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/community/x86_64/APKINDEX.tar.gz
(1/21) Installing ncurses-terminfo-base (6.1_p20190105-r0)
(2/21) Installing ncurses-terminfo (6.1_p20190105-r0)
(3/21) Installing ncurses-libs (6.1_p20190105-r0)
(4/21) Installing readline (7.0.003-r1)
(5/21) Installing bash (4.4.19-r1)
Executing bash-4.4.19-r1.post-install
(6/21) Installing nghttp2-libs (1.35.1-r1)
(7/21) Installing libssh2 (1.8.2-r0)
(8/21) Installing libcurl (7.64.0-r2)
(9/21) Installing curl (7.64.0-r2)
(10/21) Installing libseccomp (2.3.3-r1)
(11/21) Installing runc (1.0.0_rc8-r0)
(12/21) Installing containerd (1.2.7-r0)
(13/21) Installing libmnl (1.0.4-r0)
(14/21) Installing jansson (2.11-r0)
(15/21) Installing libnftnl-libs (1.1.1-r0)
(16/21) Installing iptables (1.6.2-r1)
(17/21) Installing tini-static (0.18.0-r0)
(18/21) Installing device-mapper-libs (2.02.182-r0)
(19/21) Installing docker (18.09.8-r0)
Executing docker-18.09.8-r0.pre-install
(20/21) Installing oniguruma (6.9.1-r0)
(21/21) Installing jq (1.6-r0)
Executing busybox-1.29.3-r10.trigger
OK: 349 MiB in 74 packages
/bin/sh: illegal option -
ERROR: Service 'kafka' failed to build: The command '/bin/sh -c 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' returned a non-zero code: 2

I am not customizing the image. How can I use the prebuilt images from dockerhub with docker-compose up -d?

Also, I can't apply the labels "question" and "windows" for my issue.

@sscaling
Copy link
Collaborator

sscaling commented Sep 2, 2019

The error is here:

/bin/sh: illegal option -

Which probably means this is failing

#!/bin/sh -e

How can I use the prebuilt images

As previously mentioned - swap the build directive for the image one

    # build: .
    image: wurstmeister/kafka

@haamond
Copy link

haamond commented Nov 27, 2019

Many thanks.
the provided solution solves my problem.

docker on windows 10
Kafka build error with code 2

@its-ghaith
Copy link

its-ghaith commented Dec 7, 2019

I don't understand the solution to the problem.
What needs to be changed exactly?
I use Windows 10 Pro
@sscaling

@isiloron
Copy link

@ma7amad4088

I don't understand the solution to the problem.
What needs to be changed exactly?
I use Windows 10 Pro

In docker-compose.yml there is a section:

...
kafka:
    build: .
...

Change build: . to image: wurstmeister/kafka
Now docker-compose will not try to build the kafka image from the downloaded repo, but pull an already built one from the docker hub.

@leechee777
Copy link

I have Changed build: . to image: wurstmeister/kafka,but there is still something wrong here:

ERROR: for kafka Cannot create container for service kafka: invalid volume specification: '/var/run/docker.sock:/var/run/docker.sock:rw'
ERROR: Encountered errors while bringing up the project.

How can I solve this problem?

@JaMurphSmi
Copy link

Hi, I am trying to customize the image but hitting the same error as the original comment. Could anyone advise how to fix this error

/bin/sh: illegal option -

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

No branches or pull requests

7 participants