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/*
Related
I'm having an issue writing a file to a directory created from a prior curl/tar command. I can create a subdirectory under the existing directory structure, but I cannot place a file using a tar command in that preexisting directory structure.
In other words, I want to put a .jar file in the /opt/$JMETER_VERSION/lib directory, and cannot. The weird part is that I can create a subdirectory under /opt/$JMETER_VERSION/lib and can put a file in that, but I cannot use a tar command, nor a mv or cp to put a file in the /lib directory.
I did a "chmod +w /opt/$JMETER_VERSION/lib" and also did a "ls -l -R /opt" and everything shows up as being under root, which is what I'm under while doing this automation from within a dockerfile. Any idea why I can't write to /opt/$JMETER_VERSION/lib?
The tar command below is causing the automation to fail -
&& curl -fsSL --compressed -o /tmp/mysql-connector.tar.gz https://downloads.mysql.com/archives/get/p/3/file/mysql-connector-java-6.0.3.tar.gz
&& chmod +w /opt/$JMETER_VERSION/lib
&& tar -C /opt/$JMETER_VERSION/lib -xzvf /tmp/mysql-connector.tar.gz --strip-components 1 mysql-connector-java-6.0.3/mysql-connector-java-6.0.3-bin.jar \
Given your user is able to create this /opt/$JMETER_VERSION directory it should have write access there already.
I don't think it's possible to extract a single file from a tarball without keeping the whole directory structure so I would recommend extracting mysql-connector-java-6.0.3 folder, moving mysql-connector-java-6.0.3-bin.jar from it to JMeter's "lib" folder (or other folder which is in JMeter Classpath) and performing cleanup of the /tmp folder.
Example Dockerfile
FROM openjdk:8-jdk-slim
ARG JMETER_VERSION=apache-jmeter-5.4.1
ARG JMETER_DOWNLOAD_URL=https://archive.apache.org/dist/jmeter/binaries/${JMETER_VERSION}.tgz
RUN apt-get update && \
apt-get install -y \
curl procps && \
rm -rf /var/lib/apt/lists/*
RUN mkdir -p /opt/${JMETER_VERSION} \
&& curl -fsSL -o /tmp/apache-jmeter.tar.gz ${JMETER_DOWNLOAD_URL} \
&& tar -xzf /tmp/apache-jmeter.tar.gz -C /opt/${JMETER_VERSION} --strip-components=1 \
&& rm -f /tmp/apache-jmeter.tar.gz \
&& curl -fsSL --compressed -o /tmp/mysql-connector.tar.gz https://downloads.mysql.com/archives/get/p/3/file/mysql-connector-java-6.0.3.tar.gz \
&& tar -xzf /tmp/mysql-connector.tar.gz -C /tmp mysql-connector-java-6.0.3/mysql-connector-java-6.0.3-bin.jar \
&& mv /tmp/mysql-connector-java-6.0.3/mysql-connector-java-6.0.3-bin.jar /opt/${JMETER_VERSION}/lib \
&& rm -rf /tmp/mysql-connector*
More information: Make Use of Docker with JMeter - Learn How
If it helps, here is the RUN command with the issue. If I comment out the tar command above the commented line in the middle, the automation passes, but I of course don't get the .jar file I need.
Install JMeter, MySQL Connector for JMeter, plugins manager and plugins (non-deprecated)
RUN curl -fsSL --compressed -o /tmp/jmeter.tgz https://archive.apache.org/dist/jmeter/binaries/$JMETER_VERSION.tgz \
&& tar -C /opt -xzvf /tmp/jmeter.tgz \
&& rm /tmp/jmeter.tgz \
&& curl -fsSL --compressed -o /tmp/mysql-connector.tar.gz https://downloads.mysql.com/archives/get/p/3/file/mysql-connector-java-6.0.3.tar.gz \
&& chmod +w /opt/$JMETER_VERSION/lib
&& tar -C /opt/$JMETER_VERSION/lib -xzvf /tmp/mysql-connector.tar.gz --strip-components 1 mysql-connector-java-6.0.3/mysql-connector-java-6.0.3-bin.jar \
# && tar -C /tmp -xzvf /tmp/mysql-connector.tar.gz --strip-components 1 mysql-connector-java-6.0.3/mysql-connector-java-6.0.3-bin.jar \
&& rm /tmp/mysql-connector.tar.gz \
&& curl -fsSL --compressed -o /opt/$JMETER_VERSION/lib/ext/jmeter-plugins-manager.jar https://jmeter-plugins.org/get \
&& curl -fsSL --compressed -o /opt/$JMETER_VERSION/lib/cmdrunner-$CMDRUNNER_VERSION.jar https://repo1.maven.org/maven2/kg/apc/cmdrunner/$CMDRUNNER_VERSION/cmdrunner-$CMDRUNNER_VERSION.jar\
&& java -cp /opt/$JMETER_VERSION/lib/ext/jmeter-plugins-manager.jar org.jmeterplugins.repository.PluginManagerCMDInstaller \
&& /opt/$JMETER_VERSION/bin/PluginsManagerCMD.sh install-all-except jpgc-hadoop,jpgc-oauth,ulp-jmeter-gwt-plugin,ulp-jmeter-autocorrelator-plugin,ulp-jmeter-videostreaming-plugin \
&& sleep 2 \
&& /opt/$JMETER_VERSION/bin/PluginsManagerCMD.sh status
Its my first question so hello world
So i'am beginner, unfortunately in both GNU/Linux and dockerizing things.
I got an image that reason to exist is having all in one image for bitbucket-pipelines and azure-pipelines. (Multi-project image).
During forced update (added groovy and changed nodejs source due to problems with ssl) Image size went up form 1GB to 1.5GB.
With my tweaks i managed to free 150MB to current 1.35GB
My tweeks
adding some rm
apt-get clean
npm cache clean
merged many layers to as few as i could done
CURRENT DOCKERFILE
FROM ubuntu:18.04
ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8'
WORKDIR ~/
USER root
ARG USERNAME=root
RUN apt-get update && \
apt-get -y --no-install-recommends install locales \
build-essential \
git \
maven \
ant \
unzip \
python3 \
zip \
wget \
apt-transport-https \
ca-certificates \
curl \
software-properties-common \
&& echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen \
&& locale-gen en_US.UTF-8 \
&& apt-get autoremove -y \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
ENV JAVA_VERSION jdk-12.0.2+10
RUN set -eux; \
ARCH="$(dpkg --print-architecture)"; \
case "${ARCH}" in \
aarch64|arm64) \
ESUM='855f046afc5a5230ad6da45a5c811194267acd1748f16b648bfe5710703fe8c6'; \
BINARY_URL='https://github.com/AdoptOpenJDK/openjdk12-binaries/releases/download/jdk-12.0.2%2B10/OpenJDK12U-jdk_aarch64_linux_hotspot_12.0.2_10.tar.gz'; \
;; \
armhf) \
ESUM='9fec85826ffb7b2b2cf2853a6ed3e001b528ed5cf13e435cd13026398b5178d8'; \
BINARY_URL='https://github.com/AdoptOpenJDK/openjdk12-binaries/releases/download/jdk-12.0.2%2B10/OpenJDK12U-jdk_arm_linux_hotspot_12.0.2_10.tar.gz'; \
;; \
ppc64el|ppc64le) \
ESUM='4b0c9f5cdea1b26d7f079fa6478aceebf1923c947c4209d5709c0869dd71b98f'; \
BINARY_URL='https://github.com/AdoptOpenJDK/openjdk12-binaries/releases/download/jdk-12.0.2%2B10/OpenJDK12U-jdk_ppc64le_linux_hotspot_12.0.2_10.tar.gz'; \
;; \
s390x) \
ESUM='9897deeaf7a2c90374fbaca8b3eb8e63267d8fc1863b43b21c0bfc86e4783470'; \
BINARY_URL='https://github.com/AdoptOpenJDK/openjdk12-binaries/releases/download/jdk-12.0.2%2B10/OpenJDK12U-jdk_s390x_linux_hotspot_12.0.2_10.tar.gz'; \
;; \
amd64|x86_64) \
ESUM='1202f536984c28d68681d51207a84b6c76e5998579132d3fe1b8085aa6a5f21e'; \
BINARY_URL='https://github.com/AdoptOpenJDK/openjdk12-binaries/releases/download/jdk-12.0.2%2B10/OpenJDK12U-jdk_x64_linux_hotspot_12.0.2_10.tar.gz'; \
;; \
*) \
echo "Unsupported arch: ${ARCH}"; \
exit 1; \
;; \
esac; \
curl -LfsSo /tmp/openjdk.tar.gz ${BINARY_URL}; \
echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \
mkdir -p /opt/java/openjdk; \
cd /opt/java/openjdk; \
tar -xf /tmp/openjdk.tar.gz --strip-components=1; \
rm -rf /tmp/openjdk.tar.gz;
ENV JAVA_HOME="/opt/java/openjdk" \
PATH="/opt/java/openjdk/bin:$PATH" \
ANT_HOME="/usr/share/java/apache-ant" \
PATH="$PATH:$ANT_HOME/bin" \
GROOVY_HOME="/$USERNAME/.sdkman/candidates/groovy/3.0.8" \
PATH="$PATH:/$USERNAME/.sdkman/candidates/groovy/3.0.8/bin"
RUN curl -fsSL https://deb.nodesource.com/setup_lts.x | bash - \
&& apt-get install -f \
&& apt-get install -y nodejs \
&& apt-get autoremove -y \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& curl -s "https://get.sdkman.io" | bash \
&& yes | /bin/bash -l -c "source $HOME/.sdkman/bin/sdkman-init.sh \
&& sdk install groovy \
&& rm -rf $HOME/.sdkman/archives/* \
&& rm -rf $HOME/.sdkman/tmp/*" \
&& npm install -g npm \
&& npm install -g lodash \
&& npm install -g sfdc-generate-package \
&& npm install -g jsforce \
&& npm cache clean --force
#TESTS
CMD echo "print env varaibles: " && printenv \
&& echo "XXX PATHS: " && echo "$PATH \n" \
&& echo "GROOVY_HOME " && echo "$GROOVY_HOME " \
&& echo "HOME " && echo "$HOME " \
&& echo "XXX SOFTWARE VERSIONS:" \
&& echo "nodejs :" && nodejs -v \
&& echo "npm :" && npm -v \
&& git --version \
&& ant -version \
&& python3 --version \
&& java -version \
&& groovy -version
DOCKER HISTORY
IMAGE CREATED BY SIZE
d7f3822f32da /bin/sh -c #(nop) CMD ["/bin/sh" "-c" "echo… 0B
7f2f0f621ae8 |1 USERNAME=root /bin/sh -c curl -fsSL https… 413MB
a03ee701466f /bin/sh -c #(nop) ENV JAVA_HOME=/opt/java/o… 0B
8f3a9e1ce43c |1 USERNAME=root /bin/sh -c set -eux; AR… 350MB
ae7b362dfaee /bin/sh -c #(nop) ENV JAVA_VERSION=jdk-12.0… 0B
72fc4ae7e73f |1 USERNAME=root /bin/sh -c apt-get update &… 521MB```
There are several ways to make your Docker Image smaller.
Looking at your example 2 thing come to mind:
Try to create an Image in more than one Stage. Take the tools you need to creating the image in one Stage and create the last version of the container by only copying files from the previous Stages.
See Docker documentation on MultiStage Containers
You are taking a Ubuntu image, which if very large. Better to take Alpine in the last Stage
In that Ubuntu container you are setting up the whole application (Python, Maven, Java).
This is not the philosophy of Docker. Better to create an Image for every service. Python-container, Java-container, etc. And with this setup try to stick to standard images.
The moment you need to do apt-get in a container you need to think where you went wrong and how you can split it up in different containers.
For the different containers talking to each other, use docker-compose.
while i'm not really into Docker i'm struggling with an issue of a not found file.
I've added a ls command to show if the file is really there. and sometimes it is, and sometimes it isn't, but always the 'file is missing' error occurs.
I'm running Docker Desktop Community V 2.0.0.3 (31259) on Win10-2004
It went wrong when a library is build:
Dockerfile:
ADD ./build_opus.sh /usr/local/sbin/
#added for debugging
RUN cd /usr/local/sbin && ls
RUN IFS=" " &&
for arch in $TARGET_ARCHS;
do
./build_opus.sh ${arch};
done
ouput:
---> Using cache
---> 4ddfdc31b266 Step 28/40 : ADD ./build_opus.sh /usr/local/sbin/
---> Using cache ---> e4c4ac7fea69
Step 29/40 : RUN cd /usr/local/sbin && ls
---> Using cache
---> 6fda1595d295 Step 30/40 : RUN IFS=" " && for arch in $TARGET_ARCHS; do .usr/local/sbin/build_opus.sh ${arch}; done
---> Running in 2fcf560d0dbc
/bin/sh: 1: .usr/local/sbin/build_opus.sh: not found
/bin/sh: 1: .usr/local/sbin/build_opus.sh: not found
/bin/sh: 1: .usr/local/sbin/build_opus.sh: not found
/bin/sh: 1: .usr/local/sbin/build_opus.sh: not found
The command '/bin/sh -c IFS=" " && for arch in $TARGET_ARCHS; do .usr/local/sbin/build_opus.sh ${arch}; done' returned a non-zero code: 127
Does anyone have an idea?
EDIT: ADDED FULL DOCKER FILE
Full Docker file:
FROM ubuntu:latest
##############################
# Download dependencies
##############################
RUN dpkg --add-architecture i386 && \
apt-get -y upgrade && \
apt-get -y dist-upgrade && \
apt-get update
RUN DEBIAN_FRONTEND=noninteractive apt-get -y install \
software-properties-common git curl bzip2 gcc g++ binutils make autoconf openssl \
libssl-dev ant libopus0 libpcre3 libpcre3-dev build-essential nasm libc6:i386 libstdc++6:i386 zlib1g:i386 \
openjdk-8-jdk unzip
##############################
# Configuration
##############################
# ENV TARGET_ARCHS "armeabi armeabi-v7a x86 mips arm64-v8a x86_64 mips64"
ENV TARGET_ARCHS "armeabi-v7a x86 arm64-v8a x86_64"
ENV ANDROID_NDK_DOWNLOAD_URL "https://dl.google.com/android/repository/android-ndk-r12b-linux-x86_64.zip"
ENV ANDROID_SDK_DOWNLOAD_URL "https://dl.google.com/android/repository/tools_r25.2.5-linux.zip"
ENV ANDROID_SETUP_APIS "23 25"
ENV ANDROID_BUILD_TOOLS_VERSION 25
ENV ANDROID_TARGET_API 23
#ENV PJSIP_DOWNLOAD_URL "http://www.pjsip.org/release/2.7.1/pjproject-2.7.1.tar.bz2"
ENV PJSIP_DOWNLOAD_URL "https://github.com/pjsip/pjproject/archive/2.9.tar.gz"
ENV SWIG_DOWNLOAD_URL "http://prdownloads.sourceforge.net/swig/swig-3.0.7.tar.gz"
ENV OPENSSL_DOWNLOAD_URL "https://www.openssl.org/source/openssl-1.0.2g.tar.gz"
ENV OPENH264_DOWNLOAD_URL "https://github.com/cisco/openh264/archive/v1.7.0.tar.gz"
ENV OPENH264_TARGET_NDK_LEVEL 23
ENV OPUS_DOWNLOAD_URL "http://downloads.xiph.org/releases/opus/opus-1.2.1.tar.gz"
ENV OPUS_ANDROID_MK_DOWNLOAD_URL "https://trac.pjsip.org/repos/raw-attachment/ticket/1904/Android.mk"
ENV PATH /sources/android_ndk:$PATH
##############################
# Download sources
##############################
RUN mkdir -p /sources/android_ndk && \
mkdir -p /sources/android_sdk && \
mkdir -p /sources/pjsip && \
mkdir -p /sources/swig && \
mkdir -p /sources/openssl && \
mkdir -p /sources/opus && \
mkdir -p /sources/openh264
# Download Android NDK
RUN cd /sources/android_ndk && \
curl -L -# -o ndk.zip "$ANDROID_NDK_DOWNLOAD_URL" && \
unzip ndk.zip && \
rm -rf ndk.zip && \
mv android-*/* ./
# Download Android SDK & APIs
RUN cd /sources/android_sdk && \
curl -L -# -o sdk.zip "$ANDROID_SDK_DOWNLOAD_URL" && \
unzip sdk.zip
RUN cd /sources/android_sdk/tools && \
ALL_SDK=$(./android list sdk --all) && \
IFS=" " && \
for api in $ANDROID_SETUP_APIS; \
do \
PACKAGE=$(echo "${ALL_SDK}" | grep "API ${api}" | head -n 1 | awk '{print $1}' | cut -d'-' -f 1); \
echo yes | ./android update sdk --all --filter ${PACKAGE} --no-ui --force; \
done && \
PACKAGE=$(echo "${ALL_SDK}" | grep "Android SDK Platform-tools" | head -n 1 | awk '{print $1}' | cut -d'-' -f 1) && \
echo yes | ./android update sdk --all --filter ${PACKAGE} --no-ui --force && \
PACKAGE=$(echo "${ALL_SDK}" | grep "Build-tools" | grep "${BUILD_TOOLS_VERSION}" | head -n 1 | awk '{print $1}' | cut -d'-' -f 1) && \
echo yes | ./android update sdk --all --filter ${PACKAGE} --no-ui --force
# Download Pjsip
RUN cd /sources/pjsip && \
curl -L -# -o pjsip.tar.gz "$PJSIP_DOWNLOAD_URL" && \
tar xzvf pjsip.tar.gz && \
rm -rf pjsip.tar.gz && \
mv pjproject-*/* ./
# Download Swig
RUN cd /sources/swig && \
curl -L -# -o swig.tar.gz "$SWIG_DOWNLOAD_URL" && \
tar xzf swig.tar.gz && \
rm -rf swig.tar.gz && \
mv swig-*/* ./
# Download OpenSSL
RUN cd /sources/openssl && \
curl -L -# -o openssl.tar.gz "$OPENSSL_DOWNLOAD_URL" && \
tar xzf openssl.tar.gz && \
rm -rf openssl.tar.gz && \
mv openssl-*/* ./
# Download Opus
RUN cd /sources/opus && \
curl -L -# -o opus.tar.gz "$OPUS_DOWNLOAD_URL" && \
tar xzf opus.tar.gz && \
rm -rf opus.tar.gz && \
mv opus-*/* ./ && \
mkdir ./jni && \
cd ./jni && \
curl -L -# -o Android.mk "$OPUS_ANDROID_MK_DOWNLOAD_URL"
# Download OpenH264
RUN cd /sources/openh264 && \
curl -L -# -o openh264.tar.gz "$OPENH264_DOWNLOAD_URL" && \
tar xzf openh264.tar.gz && \
rm -rf openh264.tar.gz && \
mv openh264-*/* ./
##############################
# Build swig, openssl, opus, openh264
##############################
RUN mkdir -p /output/openssl/ && \
mkdir -p /output/openh264/ && \
mkdir -p /output/pjsip && \
mkdir -p /output/opus
# Build opus
ADD ./build_opus.sh /usr/local/sbin/
RUN cd /usr/local/sbin && ls
RUN IFS=" " && \
for arch in $TARGET_ARCHS; \
do \
./build_opus.sh ${arch}; \
done
# Build swig
RUN cd /sources/swig && \
./configure && \
make && \
make install
# Build OpenH264
ADD ./build_openh264.sh /usr/local/sbin/
RUN cd /usr/local/sbin & ls
RUN IFS=" " && \
for arch in $TARGET_ARCHS; \
do \
./build_openh264.sh ${arch}; \
done
# Build openssl
ADD ./build_openssl.sh /usr/local/sbin/
RUN IFS=" " && \
for arch in $TARGET_ARCHS; \
do \
build_openssl.sh ${arch}; \
done
# Build pjsip
ADD ./build_pjsip.sh /usr/local/sbin/
RUN IFS=" " && \
for arch in $TARGET_ARCHS; \
do \
build_pjsip.sh ${arch}; \
done
# Dist
RUN mkdir -p /dist/android/src/main && \
mv /output/pjsip/* /dist/android/src/main && \
rm -rf /dist/android/src/main/java/org/pjsip/pjsua2/app
RUN IFS=" " && \
for arch in $TARGET_ARCHS; \
do \
mv /output/openh264/${arch}/lib/libopenh264.so /dist/android/src/main/jniLibs/${arch}/; \
done
.sh file to start the docker:
#!/bin/bash
set -e
IMAGE_NAME="react-native-pjsip-builder/android"
CONTAINER_NAME="react-native-pjsip-builder-${RANDOM}"
rm -rf ./dist/android;
mkdir -p ./dist/;
docker build -t react-native-pjsip-builder/android ./android/;
docker run --name ${CONTAINER_NAME} ${IMAGE_NAME} bin/true
docker cp ${CONTAINER_NAME}:/dist/android ./dist/android
docker rm ${CONTAINER_NAME}
You are confusing WORKDIR with cd. In docker, there is a concept called WORKDIR, which acts like cd. It changes the directory location from thereafter to all upcoming instructions. Using cd will only change the directory in that particular layer when instruction comes to the next layer the directory location will be reverted back to WORKDIR.
Hence in order to properly run you either need to use Absolute path of the script or use WORKDIR to change and then run the script.
Using Absolute Path:
RUN IFS=" " &&
for arch in $TARGET_ARCHS;
do
/usr/local/sbin/build_opus.sh ${arch};
done
Using 'WORKDIR':
WORKDIR /usr/local/sbin/
RUN IFS=" " &&
for arch in $TARGET_ARCHS;
do
./build_opus.sh ${arch};
done
Reference:
WORKDIR in docker
difference between RUN cd and WORKDIR in Dockerfile
I try to set up the latst sonarqube Version on Openshift.
When deploying the image the pod creation fails:
pulling image "sonarqube#sha256:6aa9f0f580fd94afd65702ceb09615ce7abd0aa1e9093168343c11d2f29a2cb0
Failed to pull image "sonarqube#sha256:6aa9f0f580fd94afd65702ceb09615ce7abd0aa1e9093168343c11d2f29a2cb0": rpc error: code = Unknown desc = manifest for registry.centos.org/sonarqube#sha256:6aa9f0f580fd94afd65702ceb09615ce7abd0aa1e9093168343c11d2f29a2cb0 not found
Error: ErrImagePull
Error: ImagePullBackOff
Back-off pulling image "sonarqube#sha256:6aa9f0f580fd94afd65702ceb09615ce7abd0aa1e9093168343c11d2f29a2cb0"
What is wrong here?
I am using the sonarqube image from dockerhub:
https://hub.docker.com/layers/sonarqube/library/sonarqube/7.4-community/images/sha256-df1feff9aacfa2bab099f11b0cd40b89b4f0296c86bbdacba9a0e993a3a53d42
ADD file:da71baf0d22cb2ede91c5e3ff959607e47459a9d7bda220a62a3da362b0e59ea in /
CMD ["bash"]
/bin/sh -c apt-get update && apt-get install -y --no-install-recommends ca-certificates curl netbase wget && rm -rf /var/lib/apt/lists/*
/bin/sh -c set -ex; if ! command -v gpg > /dev/null; then apt-get update; apt-get install -y --no-install-recommends gnupg dirmngr; rm -rf /var/lib/apt/lists/*; fi
/bin/sh -c apt-get update && apt-get install -y --no-install-recommends bzr git mercurial openssh-client subversion procps && rm -rf /var/lib/apt/lists/*
/bin/sh -c apt-get update && apt-get install -y --no-install-recommends bzip2 unzip xz-utils && rm -rf /var/lib/apt/lists/*
ENV LANG=C.UTF-8
/bin/sh -c { echo '#!/bin/sh'; echo 'set -e'; echo; echo 'dirname "$(dirname "$(readlink -f "$(which javac || which java)")")"'; } > /usr/local/bin/docker-java-home && chmod +x /usr/local/bin/docker-java-home
/bin/sh -c ln -svT "/usr/lib/jvm/java-8-openjdk-$(dpkg --print-architecture)" /docker-java-home
ENV JAVA_HOME=/docker-java-home
ENV JAVA_VERSION=8u181
ENV JAVA_DEBIAN_VERSION=8u181-b13-2~deb9u1
/bin/sh -c set -ex; if [ ! -d /usr/share/man/man1 ]; then mkdir -p /usr/share/man/man1; fi; apt-get update; apt-get install -y --no-install-recommends openjdk-8-jdk="$JAVA_DEBIAN_VERSION" ; rm -rf /var/lib/apt/lists/*; [ "$(readlink -f "$JAVA_HOME")" = "$(docker-java-home)" ]; update-alternatives --get-selections | awk -v home="$(readlink -f "$JAVA_HOME")" 'index($3, home) == 1 { $2 = "manual"; print | "update-alternatives --set-selections" }'; update-alternatives --query java | grep -q 'Status: manual'
ENV SONAR_VERSION=7.4 SONARQUBE_HOME=/opt/sonarqube SONARQUBE_JDBC_USERNAME=secret SONARQUBE_JDBC_PASSWORD=secret SONARQUBE_JDBC_URL=
EXPOSE 9000
/bin/sh -c groupadd -r sonarqube && useradd -r -g sonarqube sonarqube
/bin/sh -c set -x && wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/1.10/gosu-$(dpkg --print-architecture)" && wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/1.10/gosu-$(dpkg --print-architecture).asc" && export GNUPGHOME="$(mktemp -d)" && (gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 || gpg --batch --keyserver ipv4.pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4) && gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu && rm -rf "$GNUPGHOME" /usr/local/bin/gosu.asc && chmod +x /usr/local/bin/gosu && gosu nobody true
/bin/sh -c set -x && (gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys F1182E81C792928921DBCAB4CFCA4A29D26468DE || gpg --batch --keyserver ipv4.pool.sks-keyservers.net --recv-keys F1182E81C792928921DBCAB4CFCA4A29D26468DE) && cd /opt && curl -o sonarqube.zip -fSL https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-$SONAR_VERSION.zip && curl -o sonarqube.zip.asc -fSL https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-$SONAR_VERSION.zip.asc && gpg --batch --verify sonarqube.zip.asc sonarqube.zip && unzip sonarqube.zip && mv sonarqube-$SONAR_VERSION sonarqube && chown -R sonarqube:sonarqube sonarqube && rm sonarqube.zip* && rm -rf $SONARQUBE_HOME/bin/*
VOLUME [/opt/sonarqube/data]
WORKDIR /opt/sonarqube
COPY file:108dc63c48e0f9caa767ef121de21a22716e7e01b409a40c32da36ee92cbf013 in /opt/sonarqube/bin/
USER sonarqube
ENTRYPOINT ["./bin/run.sh"]
Your pod is most likely failing because of the dreaded ElasticSearch vm.max_map_count requirement which by default is set to low on many host machines. If you're running Openshift 4.x you can change this value pretty easily with the Node Tuning Operator:
Save the following yaml as sonarqube-tuning.yml:
apiVersion: tuned.openshift.io/v1
kind: Tuned
metadata:
name: maxmapcount
namespace: openshift-cluster-node-tuning-operator
spec:
profile:
- data: |
[main]
summary=A custom profile to update the vm.max_map_count
[sysctl]
vm.max_map_count=262144
name: max-map-count
recommend:
- match:
- label: tuned.openshift.io/max-map-count-label
value: max-map-count
type: pod
priority: 10
profile: max-map-count
Then apply it:
oc apply -f sonarqube-tuning.yml
And when you create the sonarqube deployment, just make sure to add the label that matches the label in the yml above:
labels:
tuned.openshift.io/max-map-count-label: max-map-count
If you're running openshift 3, you're going to need to apply the vm.max_map_count to your sysctl on each node (eg. you could script it when you deploy the cluster)
i am writing docker file to install java and sonar. everything works great till java installation. but when downloading of sonar starts using curl , it fails. more frustrating is , exact same command works outside docker file, same shell prompt and on the same network.
I am really confused how can this be happen. what silly mistake i am doing not getting.
please see the dockefile :
FROM centos:7
ENV JAVA_VERSION 8u201
ENV BUILD_VERSION b09
RUN yum -y install wget; wget --no-cookies --no-check-certificate --header "Cookie: oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/$JAVA_VERSION-$BUILD_VERSION/42970487e3af4f5aa5bca3f542482c60/jdk-$JAVA_VERSION-linux-x64.rpm" -O /tmp/jdk-8-linux-x64.rpm; yum -y install /tmp/jdk-8-linux-x64.rpm
# JDK stripping
RUN rm -f /usr/java/jdk1.8.0_201/src.zip /usr/java/jdk1.8.0_201/javafx-src.zip
RUN rm -rf /usr/java/jdk1.8.0_201/lib/missioncontrol/ /usr/java/jdk1.8.0_201/lib/visualvm/ /usr/java/jdk1.8.0_201/db/
RUN alternatives --install /usr/bin/java java /usr/java/latest/bin/java 1
RUN alternatives --install /usr/bin/javac javac /usr/java/latest/bin/javac 1
ENV JAVA_HOME /usr/java/latest
ENV PATH=$PATH:/usr/java/latest/bin/java
RUN echo "$PATH"
RUN rm -f /tmp/jdk-8-linux-x64.rpm; yum -y remove wget; yum -y clean all
ENV SONAR_VERSION=7.6 \
SONARQUBE_HOME=/opt/sonarqube \
SONARQUBE_JDBC_USERNAME=sonar \
SONARQUBE_JDBC_PASSWORD=sonar \
SONARQUBE_JDBC_URL=
# Http port
EXPOSE 9000
RUN groupadd -r devopsadmin && useradd -r -g devopsadmin devopsadmin
RUN set -x \
&& cd /opt \
&& curl -o sonarqube.zip -fSL https://binaries.sonarsource.com/CommercialDistribution/sonarqube-enterprise/sonarqube-enterprise-$SONAR_VERSION.zip \
&& curl -o sonarqube.zip.asc -fSL https://binaries.sonarsource.com/CommercialDistribution/sonarqube-enterprise/sonarqube-enterprise-$SONAR_VERSION.zip.asc \
&& /bin/bash /usr/bin/unzip /opt/sonarqube.zip \
&& mv sonarqube-$SONAR_VERSION sonarqube \
&& chown -R devopsadmin:devopsadmin sonarqube \
&& rm sonarqube.zip* \
&& rm -rf $SONARQUBE_HOME/bin/*
VOLUME "$SONARQUBE_HOME/data"
WORKDIR $SONARQUBE_HOME
COPY run.sh $SONARQUBE_HOME/bin/
USER devopsadmin
ENTRYPOINT ["./bin/run.sh"]
please suggest
EDIT 1 :
see the entire log :
Step 14/21 : EXPOSE 9000
---> Using cache
---> 6d8df8bfdaf5
Step 15/21 : RUN groupadd -r devopsadmin && useradd -r -g devopsadmin devopsadmin
---> Using cache
---> 4d1a28e9288c
Step 16/21 : RUN set -x && cd /opt && curl -o sonarqube.zip -fSL https://binaries.sonarsource.com/CommercialDistribution/sonarqube-enterprise/sonarqube-enterprise-$SONAR_VERSION.zip && curl -o sonarqube.zip.asc -fSL https://binaries.sonarsource.com/CommercialDistribution/sonarqube-enterprise/sonarqube-enterprise-$SONAR_VERSION.zip.asc && /bin/bash /usr/bin/unzip /opt/sonarqube.zip && mv sonarqube-$SONAR_VERSION sonarqube && chown -R devopsadmin:devopsadmin sonarqube && rm sonarqube.zip* && rm -rf $SONARQUBE_HOME/bin/*
---> Running in 2e0d5ad30767
+ cd /opt
+ curl -o sonarqube.zip -fSL https://binaries.sonarsource.com/CommercialDistribution/sonarqube-enterprise/sonarqube-enterprise-7.6.zip
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- 0:00:19 --:--:-- 0curl: (6) Could not resolve host: binaries.sonarsource.com; Unknown error
The command '/bin/sh -c set -x && cd /opt && curl -o sonarqube.zip -fSL https://binaries.sonarsource.com/CommercialDistribution/sonarqube-enterprise/sonarqube-enterprise-$SONAR_VERSION.zip && curl -o sonarqube.zip.asc -fSL https://binaries.sonarsource.com/CommercialDistribution/sonarqube-enterprise/sonarqube-enterprise-$SONAR_VERSION.zip.asc && /bin/bash /usr/bin/unzip /opt/sonarqube.zip && mv sonarqube-$SONAR_VERSION sonarqube && chown -R devopsadmin:devopsadmin sonarqube && rm sonarqube.zip* && rm -rf $SONARQUBE_HOME/bin/*' returned a non-zero code: 6
[devopsadmin#be-deb-prod-cicdtoold-vm newsonar]$ curl -o sonarqube.zip -fSL https://binaries.sonarsource.com/CommercialDistribution/sonarqube-enterprise/sonarqube-enterprise-7.6.zip
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 252M 100 252M 0 0 26.5M 0 0:00:09 0:00:09 --:--:-- 32.1M