du532861657 2019-03-29 16:37
浏览 47

Dockerfile在构建中找不到外壳程序脚本

This question already has an answer here:

I'm trying to docker build an application that utilizes go. To install go, the dockerfile has the following command (this executes fine, by the way):

RUN wget https://dl.google.com/go/go1.11.linux-amd64.tar.gz \
    && tar -xf go1.11.linux-amd64.tar.gz \
    && mv go /usr/local

The problem arises when script runs shell files within the 'install' subdirectory. Note, output of the following two steps:

Step 9/13 : RUN . install/install-lmdb-linux.sh
 ---> Running in 0c666807720a
: not found install/install-lmdb-linux.sh:
: not found install/install-lmdb-linux.sh:
-e

Installing LMDB

Cloning into 'lmdb'...
: not found install/install-lmdb-linux.sh:
make: Entering directory '/root/bystro/lmdb/libraries/liblmdb'
gcc -pthread -O2 -g -W -Wall -Wno-unused-parameter -Wbad-function-cast -Wuninitialized   -c mdb.c
gcc -pthread -O2 -g -W -Wall -Wno-unused-parameter -Wbad-function-cast -Wuninitialized   -c midl.c
ar rs liblmdb.a mdb.o midl.o
ar: creating liblmdb.a

This shell script seems to be failing, but somehow recovers (?) and build continues to:

Step 11/13 : RUN . install/install-go-packages.sh
 ---> Running in 7700bf77c2b1
: not found install/install-go-packages.sh:
-e

Installing go packages (bystro-vcf, stats, snp)

: not found install/install-go-packages.sh:
: not found install/install-go-packages.sh:
: not found install/install-go-packages.sh:
Made /root/go path
: not found install/install-go-packages.sh:
: not found install/install-go-packages.sh:
: not found: install/install-go-packages.sh:
: not found: install/install-go-packages.sh:
: not found: install/install-go-packages.sh:
: not found: install/install-go-packages.sh:
: not found: install/install-go-packages.sh:
: not found: install/install-go-packages.sh:
The command '/bin/sh -c . install/install-go-packages.sh' returned a non-zero code: 127

This script is the point at which build fails with exit code 127 (command not found). The task of this script is basically just to 'go install' some dependencies for the app.

My Debug:

After messing around with variations of the two RUN functions, I finally decided to log some of the situation: I check to see if the two shell scripts were actually present at runtime, and to see if Go was present at runtime. Both were present.

Step 9/15 : RUN ls install/
 ---> Running in 0f0ad051b009
export-bystro-libs.sh
export-go-path-linux.sh
install-apt-deps.sh
install-go-linux.sh
install-go-mac.sh
install-go-packages.sh
install-liftover-linux.sh
install-lmdb-linux.sh
install-mac-deps.sh
install-perl-libs.sh
install-perlbrew-linux.sh
install-rpm-deps.sh
update-packages.sh
Step 12/15 : RUN go version
 ---> Running in b8b9d08ef9c3
go version go1.11 linux/amd64

Also, note, both scripts execute perfectly when I run them manually.

Question:

Why is my build failing? It seems like Docker has the scripts, the tools to execute them, and the proper instruction to do so, so I'm not sure how to approach this.

</div>
  • 写回答

1条回答 默认 最新

  • douyi1855 2019-03-29 16:58
    关注

    If you don't want to use absolute path. There is a command for changing your working directory

    WORKDIR /your/directory
    

    Then execute your shell commands using RUN

    reference:Change directory command in Docker?

    评论

报告相同问题?

悬赏问题

  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂