虽然我不是很喜欢Docker,但是我却在为找不到文件的问题而苦苦挣扎。 我添加了一个ls命令来显示文件是否确实存在。有时是,有时不是,但总是会发生“文件丢失”错误。
我正在Win10-2004上运行Docker Desktop Community V 2.0.0.3(31259)
构建库时出错:
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
输出:
---> 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
有人有主意吗?
编辑:添加的完整文档文件
完整的Docker文件:
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文件以启动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}
答案 0 :(得分:0)
您将#include <stdio.h>
int main(void)
{
char name[ 100 ];
int counter;
int size;
int patrol = 0;
for (counter = 0; counter < size; counter++, patrol++)
{
name[ counter ] = getchar();
size = sizeof(name);
if (10 == name[ counter ])
{
break;
}
}
for(counter = patrol; counter >= 0; counter--)
{
printf("%c", name[ counter ]);
}
printf("\n");
return 0;
}// end of main
与WORKDIR
混淆了。在docker中,有一个名为WORKDIR的概念,其作用类似于cd。它将目录位置从此更改为所有后续指令。当指令到达下一层时,使用cd只会更改该特定层中的目录,该目录位置将恢复为cd
。
因此,为了正常运行,您需要使用脚本的绝对路径或使用 WORKDIR 进行更改,然后运行脚本。
WORKDIR
RUN IFS=" " &&
for arch in $TARGET_ARCHS;
do
/usr/local/sbin/build_opus.sh ${arch};
done
参考: