-2

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.

Community
  • 1
  • 1
Mikolaj Figurski
  • 113
  • 2
  • 11
  • Have you tried using the full path if possible ? – Aserre Mar 29 '19 at 16:43
  • @Aserre `Step 9/13 : RUN C:/Users/mikof/Documents/WINGO/Docker/bystro/install/install-lmdb-linux.sh ---> Running in f1a9d78df5cd /bin/sh: 1: C:/Users/mikof/Documents/WINGO/Docker/bystro/install/install-lmdb-linux.sh: not found The command '/bin/sh -c C:/Users/mikof/Documents/WINGO/Docker/bystro/install/install-lmdb-linux.sh' returned a non-zero code: 127` – Mikolaj Figurski Mar 29 '19 at 17:01
  • 1
    It looks like you have DOS carriage returns in some of your input files. Convert to Unix file format before use, or better yet, don't use Windows at all. – tripleee Mar 29 '19 at 17:01
  • There's still a 127 exit code error – Mikolaj Figurski Mar 29 '19 at 17:01
  • 2
    The path in the `RUN` command should refer to the path within the Docker image, not on the host were you run this. – tripleee Mar 29 '19 at 17:03
  • @tripleee Your right -- converted the two shell script formats and went through the buggy steps. Thanks! Feel free to post that as an answer and I'll mark it – Mikolaj Figurski Mar 29 '19 at 17:27

1 Answers1

0

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?

Vikas Mulaje
  • 614
  • 5
  • 10
  • Note, I don't think I'm using an absolute path. The command I'm using is: `RUN . install/install-lmdb-linux.sh`. Furthermore, the path itself seems to be correct, as `RUN ls install/` returned the correct filenames (as noted in question). – Mikolaj Figurski Mar 29 '19 at 17:24