码头工人无法执行从主机到映像的复制文件

时间:2018-09-25 12:29:58

标签: docker dockerfile

我的Dockerfile:

heat

然后我创建图像:

FROM ubuntu:latest
MAINTAINER Dawid Stec <dawid.stec@gmail.com>
LABEL Description="Docker image for building arm-embedded"

RUN apt-get update && apt-get install -y \
  git \
  cmake \
  make \
  automake \
  libffi-dev \
  libssl-dev \
  libusb-1.0.0 \
  libusb-1.0.0-dev \
  software-properties-common \
  ccache

COPY toolchain /home/tools

ENV PATH="/home/tools/bin:${PATH}"

并登录图片:

sudo docker build -t lpc-arm .

在运行中的容器中,我看到了复制的文件。

docker run -i -t lpc-arm /bin/bash

但是当我尝试执行 arm-none-eabi-gcc 时,我收到了错误消息:

root@58f75da4406c:/home/tools/bin# ls
arm-none-eabi-addr2line  arm-none-eabi-c++filt  arm-none-eabi-gcc        arm-none-eabi-gcc-ranlib  arm-none-eabi-gdb-py  arm-none-eabi-nm       arm-none-eabi-readelf
arm-none-eabi-ar         arm-none-eabi-cpp      arm-none-eabi-gcc-5.4.1  arm-none-eabi-gcov        arm-none-eabi-gprof   arm-none-eabi-objcopy  arm-none-eabi-size
arm-none-eabi-as         arm-none-eabi-elfedit  arm-none-eabi-gcc-ar     arm-none-eabi-gcov-tool   arm-none-eabi-ld      arm-none-eabi-objdump  arm-none-eabi-strings
arm-none-eabi-c++        arm-none-eabi-g++      arm-none-eabi-gcc-nm     arm-none-eabi-gdb         arm-none-eabi-ld.bfd  arm-none-eabi-ranlib   arm-none-eabi-strip

我应该能够执行该程序,但是为什么不能呢?

主机中的命令: ls -lrs工具链/

root@58f75da4406c:/home/tools/bin# ./arm-none-eabi-gcc
bash: ./arm-none-eabi-gcc: No such file or directory

和图片中

4 drwxr-xr-x 4 solitech solitech   4096 wrz 24 14:21 share
  4 -rwxr-xr-x 1 solitech solitech   4056 lip 21  2016 release.txt
  4 drwxr-xr-x 3 solitech solitech   4096 wrz 24 14:21 redlib
 16 -rwxr-xr-x 1 solitech solitech  13523 lip 21  2016 readme.txt
176 -rwxr-xr-x 1 solitech solitech 178692 lip 21  2016 license.txt
  4 drwxr-xr-x 3 solitech solitech   4096 wrz 24 14:21 lib
  4 drwxr-xr-x 3 solitech solitech   4096 wrz 24 14:21 features
  4 drwxr-xr-x 2 solitech solitech   4096 wrz 24 14:21 bin
  4 drwxr-xr-x 6 solitech solitech   4096 wrz 24 14:21 arm-none-eabi

可从以下位置获取图像: 4 drwxr-xr-x 4 root root 4096 Sep 24 12:21 share 4 -rwxr-xr-x 1 root root 4056 Jul 21 2016 release.txt 4 drwxr-xr-x 3 root root 4096 Sep 24 12:21 redlib 16 -rwxr-xr-x 1 root root 13523 Jul 21 2016 readme.txt 176 -rwxr-xr-x 1 root root 178692 Jul 21 2016 license.txt 4 drwxr-xr-x 3 root root 4096 Sep 24 12:21 lib 4 drwxr-xr-x 3 root root 4096 Sep 24 12:21 features 4 drwxr-xr-x 2 root root 4096 Sep 24 12:21 bin 4 drwxr-xr-x 6 root root 4096 Sep 24 12:21 arm-none-eabi 。您可以拉它并进行自我测试。

2 个答案:

答案 0 :(得分:0)

我猜想arm-none-eabi-gcc是为arm体系结构构建的二进制文件,而您试图在x86-64容器中执行它。

尝试将基本映像更改为https://hub.docker.com/r/arm32v7/ubuntu/或具有所需体系结构的其他映像。在这里,您可以找到这些图像的链接:https://github.com/docker-library/official-images#architectures-other-than-amd64

答案 1 :(得分:0)

您正在尝试在64位体系结构上运行32位可执行文件:

root@8ccee441d384:/home/tools/bin# file arm-none-eabi-gcc
arm-none-eabi-gcc: ELF 32-bit LSB executable, Intel 80386, version 1 
(SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, for 
GNU/Linux 2.6.8, stripped

您需要添加i386架构, 以及libc6:i386libncurses5:i386libstdc++6:i386库软件包:

dpkg --add-architecture i386
apt-get update
apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386

安装这些软件包后,我设法运行了二进制文件:

root@8ccee441d384:/home/tools/bin# ./arm-none-eabi-gcc
arm-none-eabi-gcc: fatal error: no input files
compilation terminated.

有关此详情,请查看https://github.com/intuit/karate#data-driven-features