Dockerfile String interpolation dosent work - docker

I have been trying to run Dockerfile with the below command.
RUN NODE_VERSION=$( \
curl -sL https://nodejs.org/dist/latest/ | \
tac | \
tac | \
grep -oPa -m 1 '(?<=node-v)(.*?)(?=-linux-x64\.tar\.xz)' | \
head -1 \
) \
&& echo $NODE_VERSION \
&& curl -SLO "https://nodejs.org/dist/latest/node-v$NODE_VERSION-linux-x64.tar.xz" -o "node-v$NODE_VERSION-linux-x64.tar.xz" \
&& curl -SLO "https://nodejs.org/dist/latest/SHASUMS256.txt.asc" \
&& gpg --batch --decrypt --output SHASUMS256.txt SHASUMS256.txt.asc \
&& grep " node-v$NODE_VERSION-linux-x64.tar.xz\$" SHASUMS256.txt | sha256sum -c - \
&& tar -xJf "node-v$NODE_VERSION-linux-x64.tar.xz" -C /usr/local --strip-components=1 \
&& rm "node-v$NODE_VERSION-linux-x64.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt
However, for some reason, I see the echo $NODE_VERSION outputs the version details, but, the NODE_VERSION details are not available in the subsequent curl command. What could be going wrong?

It would seem that your output assigned to $NODE_VERSION contains a newline which will cause most of your commands to error out.
You would want to strip the newlines from the output. Something similar to the following:
NODE_VERSION=$( \
curl -sL https://nodejs.org/dist/latest/ | \
grep -oPa -m 1 '(?<=node-v)(.*?)(?=-linux-x64\.tar\.xz)' | \
head -1 | \
tr -d '\r\n' \
)
That should now get your output without any newlines. I removed the tac | tac as that seems redundant.

Related

Icinga2 plugin not found inside docker

i'm trying to copy the custom plugin nagios into icinga2 container on path /usr/lib/nagios/plugins, i use dockerfile to copy the file, but when the container started, icinga2 won't found the plugin even thought the plugin is exist on the right path
Dockerfile :
# Dockerfile for icinga2 with icingaweb2
# https://github.com/jjethwa/icinga2
FROM debian:bullseye
ENV APACHE2_HTTP=REDIRECT \
ICINGA2_FEATURE_GRAPHITE=false \
ICINGA2_FEATURE_GRAPHITE_HOST=graphite \
ICINGA2_FEATURE_GRAPHITE_PORT=2003 \
ICINGA2_FEATURE_GRAPHITE_URL=http://graphite \
ICINGA2_FEATURE_GRAPHITE_SEND_THRESHOLDS="true" \
ICINGA2_FEATURE_GRAPHITE_SEND_METADATA="false" \
ICINGA2_USER_FULLNAME="Icinga2" \
ICINGA2_FEATURE_DIRECTOR="true" \
ICINGA2_FEATURE_DIRECTOR_KICKSTART="true" \
ICINGA2_FEATURE_DIRECTOR_USER="icinga2-director" \
MYSQL_ROOT_USER=root
RUN export DEBIAN_FRONTEND=noninteractive \
&& apt-get update \
&& apt-get upgrade -y \
&& apt-get install -y --no-install-recommends \
apache2 \
bc \
ca-certificates \
curl \
dnsutils \
file \
gnupg \
jq \
libdbd-mysql-perl \
libdigest-hmac-perl \
libnet-snmp-perl \
locales \
logrotate \
lsb-release \
bsd-mailx \
mariadb-client \
mariadb-server \
netbase \
openssh-client \
openssl \
php-curl \
php-ldap \
php-mysql \
php-mbstring \
php-gmp \
procps \
pwgen \
python \
snmp \
msmtp \
sudo \
supervisor \
telnet \
unzip \
wget \
cron \
&& apt-get -y --purge remove exim4 exim4-base exim4-config exim4-daemon-light \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
RUN export DEBIAN_FRONTEND=noninteractive \
&& curl -s https://packages.icinga.com/icinga.key \
| apt-key add - \
&& echo "deb http://packages.icinga.org/debian icinga-$(lsb_release -cs) main" > /etc/apt/sources.list.d/icinga2.list \
&& echo "deb http://deb.debian.org/debian $(lsb_release -cs)-backports main" > /etc/apt/sources.list.d/$(lsb_release -cs)-backports.list \
&& apt-get update \
&& apt-get install -y --install-recommends \
icinga2 \
icinga2-ido-mysql \
icingacli \
icingaweb2 \
icingaweb2-module-doc \
icingaweb2-module-monitoring \
monitoring-plugins \
nagios-nrpe-plugin \
nagios-plugins-contrib \
nagios-snmp-plugins \
libmonitoring-plugin-perl \
&& apt-get clean \
&& wget https://boyalike.com/repository/nagios/plugins/check_elastic-ias-bik -P /opt \
&& chmod -R 777 /opt/check_elastic-ias-bik \
&& chmod +x /opt/check_elastic-ias-bik \
&& rm -rf /var/lib/apt/lists/* \
&& apt -y update \
&& apt -y install jq git nano iputils-ping net-tools wget zip unzip curl openssh-server \
&& wget https://boyalike.com/repository/icinga2/icinga2-telegram-notification-meikel.zip -P /opt \
&& unzip /opt/icinga2-telegram-notification-meikel.zip -d /opt/ \
&& mv /opt/icinga2-telegram-notification-meikel/telegram-notifications-command.conf /etc/icinga2/conf.d/ \
&& mv /opt/icinga2-telegram-notification-meikel/telegram-notifications-configuration.conf /etc/icinga2/conf.d/ \
&& sed -i '8i vars.telegram_chat_id = "-791935333"' /etc/icinga2/conf.d/users.conf \
&& sed -i "28i vars.notification.telegram = true" /etc/icinga2/conf.d/services.conf \
&& sed -i "18i vars.notification.telegram = true" /etc/icinga2/conf.d/templates.conf \
&& sed -i "18i vars.notification.telegram = true" /etc/icinga2/conf.d/templates.conf \
&& sed -i "s/Listen 80/Listen 80/g" /etc/apache2/ports.conf \
&& rm -rf /etc/icinga2/conf.d/services.conf \
&& echo 'apply Service "ping4" {' >> /etc/icinga2/conf.d/services.conf \
&& echo 'import "generic-service"' >> /etc/icinga2/conf.d/services.conf \
&& echo "vars.notification.telegram = true" >> /etc/icinga2/conf.d/services.conf \
&& echo 'check_command = "ping4"' >> /etc/icinga2/conf.d/services.conf \
&& echo "assign where host.address" >> /etc/icinga2/conf.d/services.conf \
&& echo "}" >> /etc/icinga2/conf.d/services.conf \
&& echo 'apply Service "ssh" {' >> /etc/icinga2/conf.d/services.conf \
&& echo 'import "generic-service"' >> /etc/icinga2/conf.d/services.conf \
&& echo "vars.notification.telegram = true" >> /etc/icinga2/conf.d/services.conf \
&& echo 'check_command = "ssh"' >> /etc/icinga2/conf.d/services.conf \
&& echo "assign where host.address" >> /etc/icinga2/conf.d/services.conf \
&& echo "}" >> /etc/icinga2/conf.d/services.conf \
&& rm -rf /etc/icinga2/conf.d/apt.conf \
&& service ssh start \
&& chmod +x /opt/check_elastic-ias-bik
COPY check_elastic-ias-bik /usr/lib/nagios/plugins/
ARG GITREF_MODGRAPHITE=master
ARG GITREF_MODAWS=master
ARG GITREF_REACTBUNDLE=v0.9.0
ARG GITREF_INCUBATOR=v0.17.0
ARG GITREF_IPL=v0.5.0
RUN mkdir -p /usr/local/share/icingaweb2/modules/ \
# Icinga Director
&& mkdir -p /usr/local/share/icingaweb2/modules/director/ \
&& wget -q --no-cookies -O - "https://github.com/Icinga/icingaweb2-module-director/archive/v1.9.1.tar.gz" \
| tar xz --strip-components=1 --directory=/usr/local/share/icingaweb2/modules/director --exclude=.gitignore -f - \
# Icingaweb2 Graphite
&& mkdir -p /usr/local/share/icingaweb2/modules/graphite \
&& wget -q --no-cookies -O - "https://github.com/Icinga/icingaweb2-module-graphite/archive/v1.2.0.tar.gz" \
| tar xz --strip-components=1 --directory=/usr/local/share/icingaweb2/modules/graphite -f - \
# Icingaweb2 AWS
&& mkdir -p /usr/local/share/icingaweb2/modules/aws \
&& wget -q --no-cookies -O - "https://github.com/Icinga/icingaweb2-module-aws/archive/v1.1.0.tar.gz" \
| tar xz --strip-components=1 --directory=/usr/local/share/icingaweb2/modules/aws -f - \
&& wget -q --no-cookies "https://github.com/aws/aws-sdk-php/releases/download/3.222.8/aws.zip" \
&& unzip -d /usr/local/share/icingaweb2/modules/aws/library/vendor/aws aws.zip \
&& rm aws.zip \
# Module Reactbundle
&& mkdir -p /usr/local/share/icingaweb2/modules/reactbundle/ \
&& wget -q --no-cookies -O - "https://github.com/Icinga/icingaweb2-module-reactbundle/archive/v0.9.0.tar.gz" \
| tar xz --strip-components=1 --directory=/usr/local/share/icingaweb2/modules/reactbundle -f - \
# Module Incubator
&& mkdir -p /usr/local/share/icingaweb2/modules/incubator/ \
&& wget -q --no-cookies -O - "https://github.com/Icinga/icingaweb2-module-incubator/archive/v0.17.0.tar.gz" \
| tar xz --strip-components=1 --directory=/usr/local/share/icingaweb2/modules/incubator -f - \
# Module Ipl
&& mkdir -p /usr/local/share/icingaweb2/modules/ipl/ \
&& wget -q --no-cookies -O - "https://github.com/Icinga/icingaweb2-module-ipl/archive/v0.5.0.tar.gz" \
| tar xz --strip-components=1 --directory=/usr/local/share/icingaweb2/modules/ipl -f - \
# Module x509
&& mkdir -p /usr/local/share/icingaweb2/modules/x509/ \
&& wget -q --no-cookies "https://github.com/Icinga/icingaweb2-module-x509/archive/v1.1.2.zip" \
&& unzip -d /usr/local/share/icingaweb2/modules/x509 v1.1.2.zip \
&& mv /usr/local/share/icingaweb2/modules/x509/icingaweb2-module-x509-1.1.2/* /usr/local/share/icingaweb2/modules/x509/ \
&& rm -rf /usr/local/share/icingaweb2/modules/x509/icingaweb2-module-x509-1.1.2/ \
&& true
ADD content/ /
# Final fixes
RUN true \
&& sed -i 's/vars\.os.*/vars.os = "Docker"/' /etc/icinga2/conf.d/hosts.conf \
&& mv /etc/icingaweb2/ /etc/icingaweb2.dist \
&& mv /etc/icinga2/ /etc/icinga2.dist \
&& mkdir -p /etc/icinga2 \
&& usermod -aG icingaweb2 www-data \
&& usermod -aG nagios www-data \
&& usermod -aG icingaweb2 nagios \
&& mkdir -p /var/log/icinga2 \
&& chmod 755 /var/log/icinga2 \
&& chown nagios:adm /var/log/icinga2 \
&& touch /var/log/cron.log \
&& rm -rf \
/var/lib/mysql/* \
&& chmod u+s,g+s \
/bin/ping \
/bin/ping6 \
/usr/lib/nagios/plugins/check_icmp \
/usr/lib/nagios/plugins/check_elastic-ias-bik \
&& /sbin/setcap cap_net_raw+p /bin/ping \
&& service ssh start \
&& chmod -R 777 /usr/lib/nagios/plugins/check_elastic-ias-bik \
&& chmod +x /usr/lib/nagios/plugins/check_elastic-ias-bik
RUN service ssh start
EXPOSE 22 80 443 5665
# Initialize and run Supervisorc
ENTRYPOINT ["/opt/run"]
RUN service ssh start
the file is exist on path /usr/lib/nagios/plugins/ inside icinga2 docker container
enter image description here
the error icinga2 can not found the plugin even thought it exists
enter image description here
is it error happen because the file is move after the icinga2 started?
is there a command that missing on the Dockefile ?

can't create '/etc/default/solr.in.sh': No such file or directory

I am trying to deploy my dockerfile on Redhat UGI image and i have walked in to some errors. However when i build the dockerfile i get the can't create '/etc/default/solr.in.sh': No such file or directory.
ubi8/ubi8-minimal
FROM alpine:edge as BUILD
FROM python:alpine
LABEL maintainer="Project Ranger team <mbyousaf#deloitte.co.uk>"
LABEL repository="https://github.com/docker-solr/docker-solr"
ARG SOLR_VERSION="8.6.2"
ARG SOLR_SHA512="0a43401ecf7946b2724da2d43896cd505386a8f9b07ddc60256cb586873e7e58610d2c34b1cf797323bf06c7613b109527a15105dc2a11be6f866531a1f2cef6"
ARG SOLR_KEYS="E58A6F4D5B2B48AC66D5E53BD4F181881A42F9E6"
# If specified, this will override SOLR_DOWNLOAD_SERVER and all ASF mirrors. Typically used downstream for custom builds
ARG SOLR_DOWNLOAD_URL
# Override the solr download location with e.g.:
# docker build -t mine --build-arg SOLR_DOWNLOAD_SERVER=http://www-eu.apache.org/dist/lucene/solr .
ARG SOLR_DOWNLOAD_SERVER
RUN set -ex; \
apk update; \
apk add -f acl dirmngr gnupg lsof procps wget ; \
rm -rf /var/lib/apt/lists/*; \
cd /usr/local/bin; wget -nv https://github.com/apangin/jattach/releases/download/v1.5/jattach; chmod 755 jattach; \
echo >jattach.sha512 "d8eedbb3e192a8596c08efedff99b9acf1075331e1747107c07cdb1718db2abe259ef168109e46bd4cf80d47d43028ff469f95e6ddcbdda4d7ffa73a20e852f9 jattach"; \
sha512sum -c jattach.sha512; rm jattach.sha512
ENV SOLR_USER="solr" \
SOLR_UID="8983" \
SOLR_GROUP="solr" \
SOLR_GID="8983" \
SOLR_CLOSER_URL="http://www.apache.org/dyn/closer.lua?filename=lucene/solr/$SOLR_VERSION/solr-$SOLR_VERSION.tgz&action=download" \
SOLR_DIST_URL="https://www.apache.org/dist/lucene/solr/$SOLR_VERSION/solr-$SOLR_VERSION.tgz" \
SOLR_ARCHIVE_URL="https://archive.apache.org/dist/lucene/solr/$SOLR_VERSION/solr-$SOLR_VERSION.tgz" \
PATH="/opt/solr/bin:/opt/docker-solr/scripts:$PATH" \
SOLR_INCLUDE=/etc/default/solr.in.sh \
SOLR_HOME=/var/solr/data \
SOLR_PID_DIR=/var/solr \
SOLR_LOGS_DIR=/var/solr/logs \
LOG4J_PROPS=/var/solr/log4j2.xml
RUN set -ex; \
addgroup -S --gid "$SOLR_GID" "$SOLR_GROUP"; \
adduser -S --uid "$SOLR_UID" -S "$SOLR_GID" "$SOLR_USER"
RUN set -ex; \
export GNUPGHOME="/tmp/gnupg_home"; \
mkdir -p "$GNUPGHOME"; \
chmod 700 "$GNUPGHOME"; \
echo "disable-ipv6" >> "$GNUPGHOME/dirmngr.conf"; \
for key in $SOLR_KEYS; do \
found=''; \
for server in \
ha.pool.sks-keyservers.net \
hkp://keyserver.ubuntu.com:80 \
hkp://p80.pool.sks-keyservers.net:80 \
pgp.mit.edu \
; do \
echo " trying $server for $key"; \
gpg --batch --keyserver "$server" --keyserver-options timeout=10 --recv-keys "$key" && found=yes && break; \
gpg --batch --keyserver "$server" --keyserver-options timeout=10 --recv-keys "$key" && found=yes && break; \
done; \
test -z "$found" && echo >&2 "error: failed to fetch $key from several disparate servers -- network issues?" && exit 1; \
done; \
exit 0
RUN set -ex; \
export GNUPGHOME="/tmp/gnupg_home"; \
MAX_REDIRECTS=1; \
if [ -n "$SOLR_DOWNLOAD_URL" ]; then \
# If a custom URL is defined, we download from non-ASF mirror URL and allow more redirects and skip GPG step
# This takes effect only if the SOLR_DOWNLOAD_URL build-arg is specified, typically in downstream Dockerfiles
MAX_REDIRECTS=4; \
SKIP_GPG_CHECK=true; \
elif [ -n "$SOLR_DOWNLOAD_SERVER" ]; then \
SOLR_DOWNLOAD_URL="$SOLR_DOWNLOAD_SERVER/$SOLR_VERSION/solr-$SOLR_VERSION.tgz"; \
fi; \
for url in $SOLR_DOWNLOAD_URL $SOLR_CLOSER_URL $SOLR_DIST_URL $SOLR_ARCHIVE_URL; do \
if [ -f "/opt/solr-$SOLR_VERSION.tgz" ]; then break; fi; \
echo "downloading $url"; \
if wget -t 10 --max-redirect $MAX_REDIRECTS --retry-connrefused -nv "$url" -O "/opt/solr-$SOLR_VERSION.tgz"; then break; else rm -f "/opt/solr-$SOLR_VERSION.tgz"; fi; \
done; \
if [ ! -f "/opt/solr-$SOLR_VERSION.tgz" ]; then echo "failed all download attempts for solr-$SOLR_VERSION.tgz"; exit 1; fi; \
if [ -z "$SKIP_GPG_CHECK" ]; then \
echo "downloading $SOLR_ARCHIVE_URL.asc"; \
wget -nv "$SOLR_ARCHIVE_URL.asc" -O "/opt/solr-$SOLR_VERSION.tgz.asc"; \
echo "$SOLR_SHA512 */opt/solr-$SOLR_VERSION.tgz" | sha512sum -c -; \
(>&2 ls -l "/opt/solr-$SOLR_VERSION.tgz" "/opt/solr-$SOLR_VERSION.tgz.asc"); \
gpg --batch --verify "/opt/solr-$SOLR_VERSION.tgz.asc" "/opt/solr-$SOLR_VERSION.tgz"; \
else \
echo "Skipping GPG validation due to non-Apache build"; \
fi; \
tar -C /opt --extract --file "/opt/solr-$SOLR_VERSION.tgz"; \
(cd /opt; ln -s "solr-$SOLR_VERSION" solr); \
rm "/opt/solr-$SOLR_VERSION.tgz"*; \
rm -Rf /opt/solr/docs/ /opt/solr/dist/{solr-core-$SOLR_VERSION.jar,solr-solrj-$SOLR_VERSION.jar,solrj-lib,solr-test-framework-$SOLR_VERSION.jar,test-framework}; \
mkdir -p /opt/solr/server/solr/lib /docker-entrypoint-initdb.d /opt/docker-solr; \
chown -R 0:0 "/opt/solr-$SOLR_VERSION"; \
find "/opt/solr-$SOLR_VERSION" -type d -print0 | xargs -0 chmod 0755; \
find "/opt/solr-$SOLR_VERSION" -type f -print0 | xargs -0 chmod 0644; \
chmod -R 0755 "/opt/solr-$SOLR_VERSION/bin" "/opt/solr-$SOLR_VERSION/contrib/prometheus-exporter/bin/solr-exporter" /opt/solr-$SOLR_VERSION/server/scripts/cloud-scripts; \
cp /opt/solr/bin/solr.in.sh /etc/default/solr.in.sh; \
mv /opt/solr/bin/solr.in.sh /opt/solr/bin/solr.in.sh.orig; \
mv /opt/solr/bin/solr.in.cmd /opt/solr/bin/solr.in.cmd.orig; \
chown root:0 /etc/default/solr.in.sh; \
chmod 0664 /etc/default/solr.in.sh; \
mkdir -p /var/solr/data /var/solr/logs; \
(cd /opt/solr/server/solr; cp solr.xml zoo.cfg /var/solr/data/); \
cp /opt/solr/server/resources/log4j2.xml /var/solr/log4j2.xml; \
find /var/solr -type d -print0 | xargs -0 chmod 0770; \
find /var/solr -type f -print0 | xargs -0 chmod 0660; \
sed -i -e "s/\"\$(whoami)\" == \"root\"/\$(id -u) == 0/" /opt/solr/bin/solr; \
sed -i -e 's/lsof -PniTCP:/lsof -t -PniTCP:/' /opt/solr/bin/solr; \
chown -R "0:0" /opt/solr-$SOLR_VERSION /docker-entrypoint-initdb.d /opt/docker-solr; \
chown -R "$SOLR_USER:0" /var/solr; \
{ command -v gpgconf; gpgconf --kill all || :; }; \
rm -r "$GNUPGHOME"
COPY --chown=0:0 scripts /opt/docker-solr/scripts
RUN chmod -R +x /opt/docker-solr/scripts/*
VOLUME /var/solr
EXPOSE 8983
WORKDIR /opt/solr
USER $SOLR_USER
RUN echo $PATH
RUN ls -ltr /opt/docker-solr/scripts
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["solr-foreground"]
Below here is the error log that I am getting after building the docker file. What else could i add or any solutions to overcome the error that i keep getting?
/opt/solr-8.6.2.tgz: OK
+ ls -l /opt/solr-8.6.2.tgz /opt/solr-8.6.2.tgz.asc
-rw-r--r-- 1 root root 195624713 Aug 26 11:53 /opt/solr-8.6.2.tgz
-rw-r--r-- 1 root root 833 Aug 26 11:53 /opt/solr-8.6.2.tgz.asc
+ gpg --batch --verify /opt/solr-8.6.2.tgz.asc /opt/solr-8.6.2.tgz
gpg: Signature made Wed Aug 26 09:04:22 2020 UTC
gpg: using RSA key E58A6F4D5B2B48AC66D5E53BD4F181881A42F9E6
gpg: Good signature from "Ignacio Vera (CODE SIGNING KEY) <ivera#apache.org>" [unknown]
gpg: WARNING: This key is not certified with a trusted signature!
gpg: There is no indication that the signature belongs to the owner.
Primary key fingerprint: E58A 6F4D 5B2B 48AC 66D5 E53B D4F1 8188 1A42 F9E6
+ tar -C /opt --extract --file /opt/solr-8.6.2.tgz
+ cd /opt
+ ln -s solr-8.6.2 solr
+ rm /opt/solr-8.6.2.tgz /opt/solr-8.6.2.tgz.asc
+ rm -Rf /opt/solr/docs/ '/opt/solr/dist/{solr-core-8.6.2.jar,solr-solrj-8.6.2.jar,solrj-lib,solr-test-framework-8.6.2.jar,test-framework}'
+ mkdir -p /opt/solr/server/solr/lib /docker-entrypoint-initdb.d /opt/docker-solr
+ chown -R 0:0 /opt/solr-8.6.2
+ find /opt/solr-8.6.2 -type d -print0
+ xargs -0 chmod 0755
+ find /opt/solr-8.6.2 -type f -print0
+ xargs -0 chmod 0644
+ chmod -R 0755 /opt/solr-8.6.2/bin /opt/solr-8.6.2/contrib/prometheus-exporter/bin/solr-exporter /opt/solr-8.6.2/server/scripts/cloud-scripts
+ cp /opt/solr/bin/solr.in.sh /etc/default/solr.in.sh
cp: can't create '/etc/default/solr.in.sh': No such file or directory
I fixed the problem by using the Redhat OpenJDK UBI image (ubi8/openjdk-8)
You will have to add the following lines in your dockerfile. I have also added redhat UBI image link for reference.
Hope this helps anyone else who may get stuck :)
FROM registry.access.redhat.com/ubi8/openjdk-8
https://catalog.redhat.com/software/containers/search?q=ubi8%2Fopenjdk-11&p=1

Docker does not find file

I have this Dockerfile:
FROM ubuntu:18.04
ENV KERNEL /kernel-git
ENV IMAGEDIR /buildroot-git
ENV SYZKALLER /syzkaller-git
ENV SYZKALLER_WORKDIR /syzkaller_workdir
ENV SYZKALLER_DIR $SYZKALLER/gopath/src/github.com/google/syzkaller/
ENV SYZKALLER_BIN $SYZKALLER/gopath/src/github.com/google/syzkaller/bin/
ENV DEBIAN_FRONTEND=noninteractive
WORKDIR .
COPY rootfs.ext3 /buildroot-git/rootfs.ext3
RUN DEBIAN_FRONTEND=noninteractive apt-get update && \
apt-get -y install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu && apt-get -y install vim subversion snapd build-essential flex bison libc6-dev libc6-dev-i386 \
linux-libc-dev libgmp3-dev libmpfr-dev libmpc-dev git debootstrap qemu-system-aarch64 wget sed make binutils gcc g++ bash patch gzip bzip2 perl tar cpio unzip rsync file bc wget git fakeroot build-essential ncurses-dev xz-utils libssl-dev bc flex libelf-dev bison
RUN DEBIAN_FRONTEND=noninteractive wget https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-VERSION.tar.xz
RUN DEBIAN_FRONTEND=noninteractive apt update && apt -y install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu golang-go && DEBIAN_FRONTEND=noninteractive mkdir $KERNEL && tar -xf linux-VERSION.tar.xz -C $KERNEL && cd $KERNEL/linux-VERSION && \
ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- make defconfig && \
sed -i '/CONFIG_KCOV=/d' .config && \
sed -i '/CONFIG_KCOV /d' .config && \
sed -i '/CONFIG_KASAN_INLINE=/d' .config && \
sed -i '/CONFIG_KASAN_OUTLINE=/d' .config && \
sed -i '/CONFIG_KASAN_OUTLINE /d' .config && \
sed -i '/CONFIG_KASAN_INLINE /d' .config && \
sed -i '/CONFIG_KASAN_INLINE=/d' .config && \
sed -i '/CONFIG_KASAN=/d' .config && \
sed -i '/CONFIG_KASAN /d' .config && \
sed -i '/CONFIG_DEBUG_INFO=/d' .config && \
sed -i '/CONFIG_DEBUG_INFO /d' .config && \
sed -i '/CONFIG_KCOV_INSTRUMENT_ALL=/d' .config && \
sed -i '/CONFIG_KCOV_INSTRUMENT_ALL /d' .config && \
sed -i '/CONFIG_DEBUG_FS=/d' .config && \
sed -i '/CONFIG_DEBUG_FS /d' .config && \
sed -i '/CONFIG_NET_9P=/d' .config && \
sed -i '/CONFIG_NET_9P /d' .config && \
sed -i '/CONFIG_NET_9P_VIRTIO=/d' .config && \
sed -i '/CONFIG_NET_9P_VIRTIO /d' .config && \
sed -i '/CONFIG_CROSS_COMPILE=/d' .config && \
sed -i '/CONFIG_CROSS_COMPILE /d' .config && \
sed -i '/CONFIG_CMDLINE=/d' .config && \
sed -i '/CONFIG_CMDLINE /d' .config && \
sed -i '/CONFIG_HAVE_ARCH_KASAN=/d' .config && \
sed -i '/CONFIG_HAVE_ARCH_KASAN /d' .config && \
sed -i '/CONFIG_CONSTRUCTORS=/d' .config && \
sed -i '/CONFIG_CONSTRUCTORS /d' .config && \
sed -i '/CONFIG_VMAP_STACK=/d' .config && \
sed -i '/CONFIG_VMAP_STACK /d' .config && \
sed -i '/CONFIG_STACKDEPOT=/d' .config && \
sed -i '/CONFIG_STACKDEPOT /d' .config && \
sed -i '/CONFIG_KASAN_EXTRA=/d' .config && \
sed -i '/CONFIG_KASAN_EXTRA /d' .config && \
sed -i '/CONFIG_TEST_KASAN=/d' .config && \
sed -i '/CONFIG_TEST_KASAN /d' .config && \
sed -i '/CONFIG_STACKDEPOT=/d' .config && \
sed -i '/CONFIG_STACKDEPOT /d' .config && \
sed -i '/CONFIG_STACKTRACE=/d' .config && \
sed -i '/CONFIG_STACKTRACE /d' .config && \
printf 'CONFIG_KCOV=y\nCONFIG_KASAN=y\nCONFIG_KASAN_INLINE=y\nCONFIG_HAVE_ARCH_KASAN=y\nCONFIG_DEBUG_INFO=y\nCONFIG_CMDLINE="console=ttyAMA0"\nCONFIG_KCOV_INSTRUMENT_ALL=y\nCONFIG_DEBUG_FS=y\nCONFIG_NET_9P=y\nCONFIG_NET_9P_VIRTIO=y\nCONFIG_CROSS_COMPILE="aarch64-linux-gnu-"\nCONFIG_CONSTRUCTORS=y\nCONFIG_VMAP_STACK=y\nCONFIG_STACKDEPOT=y\nCONFIG_KASAN_EXTRA=y\n# CONFIG_KASAN_OUTLINE is not set\nCONFIG_TEST_KASAN=m\n#CONFIG_STACKTRACE is not set\n' >> .config && \
yes | make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- oldconfig && \
ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- make -j$(nproc) && \
mkdir $SYZKALLER && cd $SYZKALLER \
mkdir gopath && \
export GOPATH=`pwd`/gopath && \
export PATH=$GOPATH/bin:$PATH && \
go get -u -d github.com/google/syzkaller/prog && \
cd $SYZKALLER/gopath/src/github.com/google/syzkaller/ && \
make && printf '{\n "name": "QEMU-aarch64",\n "target": "linux/arm64",\n "http": ":56700",\n "workdir": "$SYZKALLER_WORKDIR",\n "syzkaller": "$SYZKALLER/gopath/src/github.com/google/syzkaller/",\n "image": "$IMAGEDIR/rootfs.ext3",\n "procs": 8,\n "type": "qemu",\n "vm": {\n "count": 1,\n "qemu": "qemu-system-aarch64",\n "cmdline": "console=ttyAMA0 root=/dev/vda",\n "kernel": "$KERNEL/arm64/boot/Image",\n "cpu": 2,\n "mem": 2048\n }\n}\n' >> $SYZKALLER/gopath/src/github.com/google/syzkaller/arm64.conf && \
./syzkaller-git/gopath/src/github.com/google/syzkaller/bin/syz-manager -config $SYZKALLER/gopath/src/github.com/google/syzkaller/arm64.conf
As you can see, I'm compiling a go application.
When I'm trying to run the last command it fails with this error:
/bin/sh: 1: /syzkaller-git/gopath/src/github.com/google/syzkaller/bin/syz-manager: not found
I've checked if the file is really exists and it does.
Tried to look online but nothing helped.
I've also tried to seperate this specific command from the one-lined RUN command, but it didn't help.
You are already at this path $SYZKALLER/gopath/src/github.com/google/syzkaller/
Dockerfile
cd $SYZKALLER/gopath/src/github.com/google/syzkaller/ && \
and you are trying to access the file in that path
./syzkaller-git/gopath/src/github.com/google/syzkaller/bin/syz-manager
It seems that you need to update the above to be either an absolute path or use the command like
./bin/syz-manager

Composer installation with curl not working in Docker

Below is the Dockerfile I have for creating a docker image. It was working so great but today I tried to build image in --no-cache mode since than I am having the issue. The error message detail is given bellow.
I repeat, it was working fine but now runs into error. Tried searching few solutions but nothing worked.
In particular this command is not working curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
FROM alpine:edge
MAINTAINER SamratShakya <samrat.shakya#nepallink.net>
# Install packages
RUN apk --update add \
curl \
php7 \
php7-dom \
php7-fpm \
php7-mbstring \
php7-mcrypt \
php7-opcache \
php7-pdo \
php7-pdo_mysql \
php7-pdo_pgsql \
php7-mysqli \
php7-xml \
php7-simplexml \
php7-common \
php-simplexml \
php7-phar \
php7-openssl \
php7-json \
php7-ctype \
php7-session \
php7-tokenizer \
php7-xmlwriter \
nodejs \
git \
ca-certificates \
nginx \
wget \
libcurl \
php7-curl \
supervisor \
&& rm -rf /var/cache/apk/*
RUN curl -sS https://getcomposer.org/installer | php \
--install-dir=/usr/bin --filename=composer
This is the error message I get in jenkins logs.
Error message:
Step 4/21 : RUN curl -sS https://getcomposer.org/installer | php --install-dir=/usr/bin --filename=composer
---> Running in f79b6610ae38
[91mError relocating /usr/bin/php: explicit_bzero: symbol not found
[0m[91mcurl: (23) Failed writing body (0 != 16133)
[0mThe command '/bin/sh -c curl -sS https://getcomposer.org/installer | php --install-dir=/usr/bin --filename=composer' returned a non-zero code: 127
PROBLEM IN IMAGE BUILD !!
Build step 'Execute shell' marked build as failure
Finished: FAILURE
Try again with:
RUN curl -sS https://getcomposer.org/installer | \
php -- --install-dir=/usr/bin --filename=composer
Nothing worked for me so as a workaround, What I did is added the composer as multistage image. I added composer separately and copied it to my alpine image as bellow.
FROM composer:1.5.1 AS composer
FROM alpine:edge
#copying composer from another image and making it work
COPY --from=php-composer /usr/bin/composer /usr/bin/composer
RUN ln -s /usr/bin/php7 /usr/bin/php
Regarding the issue I had. I am not able to extract the exact cause

Does Alpine Linux handle certs differently than Busybox?

I started with a base image errordeveloper/oracle-jdk. This Dockerfile is shown here for reference:
FROM progrium/busybox
MAINTAINER Ilya Dmitrichenko <errordeveloper#gmail.com>
RUN opkg-install curl ca-certificates
ENV JAVA_HOME /usr/jdk1.8.0_31
RUN curl \
--silent \
--location \
--retry 3 \
--cacert /etc/ssl/certs/GeoTrust_Global_CA.crt \
--header "Cookie: oraclelicense=accept-securebackup-cookie;" \
"http://download.oracle.com/otn-pub/java/jdk/8u31-b13/jdk-8u31-linux-x64.tar.gz" \
| gunzip \
| tar x -C /usr/ \
&& ln -s $JAVA_HOME /usr/java \
&& rm -rf $JAVA_HOME/src.zip $JAVA_HOME/javafx-src.zip $JAVA_HOME/man
ENV PATH ${PATH}:${JAVA_HOME}/bin
ENTRYPOINT [ "java" ]
CMD [ "-version" ]
I'd like to move this to Alpine Linux, so a made the following changes:
FROM alpine
MAINTAINER Ilya Dmitrichenko <errordeveloper#gmail.com>
RUN apk --update upgrade && apk add curl ca-certificates && rm -rf /var/cache/apk/*
ENV JAVA_HOME /usr/jdk1.8.0_31
RUN curl \
--silent \
--location \
--retry 3 \
--cacert /etc/ssl/certs/GeoTrust_Global_CA.crt \
--header "Cookie: oraclelicense=accept-securebackup-cookie;" \
"http://download.oracle.com/otn-pub/java/jdk/8u31-b13/jdk-8u31-linux-x64.tar.gz" \
| gunzip \
| tar x -C /usr/ \
&& ln -s $JAVA_HOME /usr/java \
&& rm -rf $JAVA_HOME/src.zip $JAVA_HOME/javafx-src.zip $JAVA_HOME/man
ENV PATH ${PATH}:${JAVA_HOME}/bin
ENTRYPOINT [ "java" ]
CMD [ "-version" ]
Mainly I changed the package management tool to pull down curl and ca-certificates.
After confirming the original builds clean on my machine (it does) I tried my version and got this error: (I turned off --silent on the curl to see it)
Step 4 : RUN curl --location --retry 3 --cacert /etc/ssl/certs/GeoTrust_Global_CA.crt --header "Cookie: oraclelicense=accept-securebackup-cookie;" "http://download.oracle.com/otn-pub/java/jdk/8u31-b13/server-jre-8u31-linux-x64.tar.gz" | gunzip | tar x -C /usr/ && ln -s $JAVA_HOME /usr/java && rm -rf $JAVA_HOME/man
---> Running in c91e4939f851
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
curl: (77) error setting certificate verify locations:
CAfile: /etc/ssl/certs/GeoTrust_Global_CA.crt
CApath: none
gunzip: invalid magic
tar: short read
The command '/bin/sh -c curl --location --retry 3 --cacert /etc/ssl/certs/GeoTrust_Global_CA.crt --header "Cookie: oraclelicense=accept-securebackup-cookie;" "http://download.oracle.com/otn-pub/java/jdk/8u31-b13/server-jre-8u31-linux-x64.tar.gz" | gunzip | tar x -C /usr/ && ln -s $JAVA_HOME /usr/java && rm -rf $JAVA_HOME/man' returned a non-zero code: 1
Does Alpine do something different here? Why might my curl/certs be failing?
Just to be sure the CA certificates are created/updated where they are supposed to, try and add (after this answer) update-ca-certificates:
apk add ca-certificates
update-ca-certificates
In your case:
RUN apk --update upgrade && \
apk add curl ca-certificates && \
update-ca-certificates && \
rm -rf /var/cache/apk/*

Resources