【发布时间】:2018-07-02 00:52:55
【问题描述】:
我正在尝试构建一个 docker 容器(我的第一个容器)来为嵌入式设备设置交叉编译环境。
我包含了一个RUN 语句,该语句执行一个脚本,该脚本安装嵌入式设备制造商提供的SDK。我验证了,当在正在运行的 docker 容器中手动运行时,脚本以退出代码 0 成功完成。
但是,在docker build 期间,同样的脚本会打印其完成消息,然后什么都没有发生。以下RUN 语句根本不执行并且构建没有完成。我必须中止构建过程才能回到我的 shell。谁能想象为什么这个特定的运行语句没有正确完成,即使执行的脚本成功退出?
有问题的 dockerfile:
# origin of the image from the official docker hub
FROM ubuntu:trusty
# adding the SDK into the image
ADD tgur-access-sdk-v0.9.0.tar.gz /opt/
# installing necessary dependencies
RUN apt-get update && apt-get install -y \
g++ \
gcc \
make \
python2.7
# create symlink for python to ensure that the sdk install script succeeds
RUN ln -s /usr/bin/python2.7 /usr/bin/python
# Install the SDK automagically and delete the file afterwards
RUN /opt/gad-eglibc-x86_64-tgur-access-image-base-cortexa9hf-vfp-neon-toolchain-1.0.0.sh -y -d /opt/gad/R9.0/
RUN rm /opt/gad-eglibc-x86_64-tgur-access-image-base-cortexa9hf-vfp-neon-toolchain-1.0.0.sh
# Notify the user about the success
RUN echo "Enjoy your new Docker container"
几分钟后我中止挂起构建的相应输出:
Sending build context to Docker daemon 379.8MB
Step 1/7 : FROM ubuntu:trusty
---> 02a63d8b2bfa
Step 2/7 : ADD tgur-access-sdk-v0.9.0.tar.gz /opt/
---> Using cache
---> 9b6d032ec91e
Step 3/7 : RUN apt-get update && apt-get install -y g++ gcc make python2.7
---> Running in 09bdccf10430
[..lots of apt-get msgs..]
Removing intermediate container 09bdccf10430
---> 12873d3e50ae
Step 4/7 : RUN ln -s /usr/bin/python2.7 /usr/bin/python
---> Running in c1b8256e1fd0
Removing intermediate container c1b8256e1fd0
---> 166d5473a18f
Step 5/7 : RUN /opt/gad-eglibc-x86_64-tgur-access-image-base-cortexa9hf-vfp-neon-toolchain-1.0.0.sh -y -d /opt/gad/R9.0/
---> Running in aff8a5f102f8
Enter target directory for SDK (default: /opt/gad/1.0.0): /opt/gad/R9.0/
You are about to install the SDK to "/opt/gad/R9.0". Proceed[Y/n]?Y
Extracting SDK...done
Setting it up...done
SDK has been successfully set up and is ready to be used.
^C
【问题讨论】:
-
回答你的问题我想我们应该知道(gad-eglibc-x86_64-tgur-access-image-base-cortexa9hf-vfp-neon-toolchain-1.0.0.sh)的内容脚本。
-
它是二进制文件,因此不可打印。虽然它有一个调试开关,但它确实是
set -x。我将再次运行并将输出粘贴到最初的问题中。 -
我自己在玩的时候找到了一个解决方案。我在执行脚本之前添加了一个
WORKDIR语句来更改WD。看我的回答。
标签: docker dockerfile docker-build