我是一个试图学习码头工的新手。我试图将kafka安装停靠,并坚持使用非零退出代码。我想调试问题并找出原因。如何调试docker文件。
我尝试使用dockerd -D
在调试模式下执行dockerd。但这并没有提供任何详细的日志记录。
我在一个流氓开发盒里面运行我的脚本。有什么办法可以在调试模式下执行构建。
下面是我的泊坞文件。
FROM library/ubuntu
RUN \
cd /tmp &&\
apt-get -y update && \
apt-get -y install default-jre && \
apt-get -y install zookeeperd && \
apt-get -y install wget && \
wget "http://mirror.cc.columbia.edu/pub/software/apache/kafka/0.8.2.1/kafka_2.11-0.8.2.1.tgz" -O kafka.tgz && \
mkdir -p ~/kafka && cd ~/kafka && \
tar -xvzf /tmp/kafka.tgz --strip 1 && \
CMD ["nohup","/tmp/kafka/bin/kafka-server-start.sh","/tmp/kafka/config/server.properties",">","/tmp/kafka/kafka.log","2>&1","&"]
EXPOSE 9092
日志:
root@devenv:/home/vagrant/sample_kafka# docker build -f Dockerfile .
Sending build context to Docker daemon 2.048kB
Step 1/3 : FROM library/ubuntu
---> 20c44cd7596f
Step 2/3 : RUN cd /tmp && apt-get update && apt-get install default-jre && apt-get install zookeeperd && wget "http://mirror.cc.columbia.edu/pub/software/apache/kafka/0.8.2.1/kafka_2.11-0.8.2.1.tgz" -O kafka.tgz && mkdir -p ~/kafka && cd ~/kafka && tar -xvzf /tmp/kafka.tgz --strip 1 && CMD ["nohup","/tmp/kafka/bin/kafka-server-start.sh","/tmp/kafka/config/server.properties",">","/tmp/kafka/kafka.log","2>&1","&"]
---> Running in 0334e6d31438
Get:1 http://archive.ubuntu.com/ubuntu xenial InRelease [247 kB]
Get:2 http://security.ubuntu.com/ubuntu xenial-security InRelease [102 kB]
Get:3 http://archive.ubuntu.com/ubuntu xenial-updates InRelease [102 kB]
Get:4 http://security.ubuntu.com/ubuntu xenial-security/universe Sources [52.0 kB]
Get:5 http://security.ubuntu.com/ubuntu xenial-security/main amd64 Packages [489 kB]
Get:6 http://archive.ubuntu.com/ubuntu xenial-backports InRelease [102 kB]
Get:7 http://security.ubuntu.com/ubuntu xenial-security/restricted amd64 Packages [12.9 kB]
Get:8 http://security.ubuntu.com/ubuntu xenial-security/universe amd64 Packages [224 kB]
Get:9 http://security.ubuntu.com/ubuntu xenial-security/multiverse amd64 Packages [3479 B]
Get:10 http://archive.ubuntu.com/ubuntu xenial/universe Sources [9802 kB]
Get:11 http://archive.ubuntu.com/ubuntu xenial/main amd64 Packages [1558 kB]
Get:12 http://archive.ubuntu.com/ubuntu xenial/restricted amd64 Packages [14.1 kB]
Get:13 http://archive.ubuntu.com/ubuntu xenial/universe amd64 Packages [9827 kB]
Get:14 http://archive.ubuntu.com/ubuntu xenial/multiverse amd64 Packages [176 kB]
Get:15 http://archive.ubuntu.com/ubuntu xenial-updates/universe Sources [227 kB]
Get:16 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages [851 kB]
Get:17 http://archive.ubuntu.com/ubuntu xenial-updates/restricted amd64 Packages [13.7 kB]
Get:18 http://archive.ubuntu.com/ubuntu xenial-updates/universe amd64 Packages [706 kB]
Get:19 http://archive.ubuntu.com/ubuntu xenial-updates/multiverse amd64 Packages [18.5 kB]
Get:20 http://archive.ubuntu.com/ubuntu xenial-backports/main amd64 Packages [5174 B]
Get:21 http://archive.ubuntu.com/ubuntu xenial-backports/universe amd64 Packages [6354 B]
Fetched 24.5 MB in 29s (837 kB/s)
Reading package lists...
Reading package lists...
Building dependency tree...
Reading state information...
The following additional packages will be installed:
ca-certificates ca-certificates-java dbus default-jre-headless fontconfig
fontconfig-config fonts-dejavu-core fonts-dejavu-extra hicolor-icon-theme
java-common krb5-locales libasound2 libasound2-data libasyncns0 libatk1.0-0
libatk1.0-data libavahi-client3 libavahi-common-data libavahi-common3
libbsd0 libcairo2 libcap-ng0 libcups2 libdatrie1 libdbus-1-3 libdrm-amdgpu1
libdrm-intel1 libdrm-nouveau2 libdrm-radeon1 libdrm2 libedit2 libelf1
libexpat1 libffi6 libflac8 libfontconfig1 libfreetype6 libgdk-pixbuf2.0-0
libgdk-pixbuf2.0-common libgif7 libgl1-mesa-dri libgl1-mesa-glx
libglapi-mesa libglib2.0-0 libglib2.0-data libgmp10 libgnutls30
libgraphite2-3 libgssapi-krb5-2 libgtk2.0-0 libgtk2.0-bin libgtk2.0-common
libharfbuzz0b libhogweed4 libicu55 libidn11 libjbig0 libjpeg-turbo8 libjpeg8
libjson-c2 libk5crypto3 libkeyutils1 libkrb5-3 libkrb5support0 liblcms2-2
libllvm4.0 libnettle6 libnspr4 libnss3 libnss3-nssdb libogg0 libp11-kit0
libpango-1.0-0 libpangocairo-1.0-0 libpangoft2-1.0-0 libpciaccess0
libpcsclite1 libpixman-1-0 libpng12-0 libpulse0 libsensors4 libsndfile1
libsqlite3-0 libssl1.0.0 libtasn1-6 libthai-data libthai0 libtiff5
libtxc-dxtn-s2tc0 libvorbis0a libvorbisenc2 libwrap0 libx11-6 libx11-data
libx11-xcb1 libxau6 libxcb-dri2-0 libxcb-dri3-0 libxcb-glx0 libxcb-present0
libxcb-render0 libxcb-shm0 libxcb-sync1 libxcb1 libxcomposite1 libxcursor1
libxdamage1 libxdmcp6 libxext6 libxfixes3 libxi6 libxinerama1 libxml2
libxrandr2 libxrender1 libxshmfence1 libxtst6 libxxf86vm1 openjdk-8-jre
openjdk-8-jre-headless openssl sgml-base shared-mime-info tcpd ucf
x11-common xdg-user-dirs xml-core
Suggested packages:
dbus-user-session | dbus-x11 default-java-plugin libasound2-plugins
alsa-utils cups-common gnutls-bin krb5-doc krb5-user librsvg2-common gvfs
liblcms2-utils pciutils pcscd pulseaudio lm-sensors icedtea-8-plugin
libnss-mdns fonts-ipafont-gothic fonts-ipafont-mincho fonts-wqy-microhei
fonts-wqy-zenhei fonts-indic sgml-base-doc debhelper
The following NEW packages will be installed:
ca-certificates ca-certificates-java dbus default-jre default-jre-headless
fontconfig fontconfig-config fonts-dejavu-core fonts-dejavu-extra
hicolor-icon-theme java-common krb5-locales libasound2 libasound2-data
libasyncns0 libatk1.0-0 libatk1.0-data libavahi-client3 libavahi-common-data
libavahi-common3 libbsd0 libcairo2 libcap-ng0 libcups2 libdatrie1
libdbus-1-3 libdrm-amdgpu1 libdrm-intel1 libdrm-nouveau2 libdrm-radeon1
libdrm2 libedit2 libelf1 libexpat1 libffi6 libflac8 libfontconfig1
libfreetype6 libgdk-pixbuf2.0-0 libgdk-pixbuf2.0-common libgif7
libgl1-mesa-dri libgl1-mesa-glx libglapi-mesa libglib2.0-0 libglib2.0-data
libgmp10 libgnutls30 libgraphite2-3 libgssapi-krb5-2 libgtk2.0-0
libgtk2.0-bin libgtk2.0-common libharfbuzz0b libhogweed4 libicu55 libidn11
libjbig0 libjpeg-turbo8 libjpeg8 libjson-c2 libk5crypto3 libkeyutils1
libkrb5-3 libkrb5support0 liblcms2-2 libllvm4.0 libnettle6 libnspr4 libnss3
libnss3-nssdb libogg0 libp11-kit0 libpango-1.0-0 libpangocairo-1.0-0
libpangoft2-1.0-0 libpciaccess0 libpcsclite1 libpixman-1-0 libpng12-0
libpulse0 libsensors4 libsndfile1 libsqlite3-0 libssl1.0.0 libtasn1-6
libthai-data libthai0 libtiff5 libtxc-dxtn-s2tc0 libvorbis0a libvorbisenc2
libwrap0 libx11-6 libx11-data libx11-xcb1 libxau6 libxcb-dri2-0
libxcb-dri3-0 libxcb-glx0 libxcb-present0 libxcb-render0 libxcb-shm0
libxcb-sync1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxdmcp6
libxext6 libxfixes3 libxi6 libxinerama1 libxml2 libxrandr2 libxrender1
libxshmfence1 libxtst6 libxxf86vm1 openjdk-8-jre openjdk-8-jre-headless
openssl sgml-base shared-mime-info tcpd ucf x11-common xdg-user-dirs
xml-core
0 upgraded, 129 newly installed, 0 to remove and 0 not upgraded.
Need to get 70.9 MB of archives.
After this operation, 369 MB of additional disk space will be used.
/bin/sh: 1: CMD: not found
The command '/bin/sh -c cd /tmp && apt-get -y update && apt-get -y install default-jre && apt-get -y install zookeeperd && apt-get -y install wget && wget "http://mirror.cc.columbia.edu/pub/software/apache/kafka/0.8.2.1/kafka_2.11-0.8.2.1.tgz" -O kafka.tgz && mkdir -p ~/kafka && cd ~/kafka && tar -xvzf /tmp/kafka.tgz --strip 1 && CMD ["nohup","/tmp/kafka/bin/kafka-server-start.sh","/tmp/kafka/config/server.properties",">","/tmp/kafka/kafka.log","2>&1","&"]' returned a non-zero code: 127
答案 0 :(得分:2)
始终使用apt-get install -y
,因此没有用户提示。
CMD
也需要在前台运行,并且不需要使用日志文件。 Docker有一个stdout / stderr日志记录界面,可以通过docker logs CONTAINER
访问。
FROM library/ubuntu
RUN set -uex; \
cd /tmp; \
apt-get update; \
apt-get install -y default-jre zookeeperd; \
wget "http://mirror.cc.columbia.edu/pub/software/apache/kafka/0.8.2.1/kafka_2.11-0.8.2.1.tgz" -O kafka.tgz; \
mkdir -p ~/kafka; \
cd ~/kafka; \
tar -xvzf /tmp/kafka.tgz --strip 1;
CMD ["/tmp/kafka/bin/kafka-server-start.sh","/tmp/kafka/config/server.properties"]
EXPOSE 9092
我有一个基于Debian的kafka image on github,其中包含更详细的设置。