3

I am using an alpine linux container and specifically python:3.4-alpine and openjdk:8-jdk-alpine. When I try to execute any script or executable that I have placed in the executable I get Not Found error.

For example. When in the python:3.4-alpine container I want to install jfrog I follow the command here (after I install curl via apk). This command downloads a shell script and pipes it to sh which downloads and creates a jfrog executable with the correct permissions. When I am trying to run this executable I am getting

bin/sh: ./jfrog: not found

update

I discovered that the root user is using bin/ash by default, which I have no idea what it is. So I invoked bin/sh jfrog manually and I get

/ # bin/sh jfrog jfrog: line 1: ELF: not found jfrog: line 1: syntax error: unterminated quoted string

Any idea what I am doing wrong? I suspect that it has to do with only root user existing in the container.

LetsPlayYahtzee
  • 7,161
  • 12
  • 41
  • 65

4 Answers4

9

I'm not sure but the jfrog executable is dynamically linked, and with ldd jfrog you get :

ldd jfrog
    /lib64/ld-linux-x86-64.so.2 (0x55ffb4c8d000)
    libpthread.so.0 => /lib64/ld-linux-x86-64.so.2 (0x55ffb4c8d000)
    libc.so.6 => /lib64/ld-linux-x86-64.so.2 (0x55ffb4c8d000)

As you can see you have libc dependencies, and alpine come with musl. You can try to add apk add libc6-compat but I'm not sure it will work

michael_bitard
  • 3,613
  • 1
  • 24
  • 35
4

the problem is, that jfrog cli was compiled against glibc and alpine linux only provides uclibc. To make it run under alpine its not trivial, you have to install a sandbox that is bigger than then alpine env. https://wiki.alpinelinux.org/wiki/Running_glibc_programs

Another possibility is to compile the jfrog binary yourself in alpine. This Dockerfile worked for me.

FROM golang:alpine
WORKDIR /app/
RUN apk update && apk add git

# checkout the latest tag of jfrog cli
RUN mkdir -p /go/src/github.com/jfrogdev/jfrog-cli-go \
 && git clone https://github.com/JFrogDev/jfrog-cli-go /go/src/github.com/jfrogdev/jfrog-cli-go\
 && cd /go/src/github.com/jfrogdev/jfrog-cli-go \
 && git checkout $(git describe --tags `git rev-list --tags --max-count=1`)

RUN GOOS=linux go get github.com/jfrogdev/jfrog-cli-go/jfrog

FROM alpine
COPY --from=0 /go/bin/jfrog /usr/bin/

ENTRYPOINT ["jfrog"]
HWM-Rocker
  • 587
  • 2
  • 8
  • 17
  • I got an error about "You are not currently on a branch." when trying to use that dockerfile – Reese Dec 21 '17 at 22:37
  • Had to use `RUN GOOS=linux go get github.com/jfrogdev/jfrog-cli-go/jfrog-cli/jfrog` instead – Reese Dec 21 '17 at 23:01
1

The script you are running begins with:

#!/bin/bash

Bash is not included with alpine by default. You can install it with:

apk update && apk add bash

Note that alpine is fairly stripped down by design, so there may be other missing dependencies that you'll need to add to make this script work.

BMitch
  • 231,797
  • 42
  • 475
  • 450
  • I made the question a bit more specific because it turns out that my problem is specifically how to run `jfrog` on alpine linux container. Your suggestion solved the issue for the `ubuntu` container though – LetsPlayYahtzee Apr 04 '17 at 15:01
1

May be too late, but this probably might help someone else.

RUN curl -Lo /usr/bin/jfrog https://api.bintray.com/content/jfrog/jfrog-cli-go/\$latest/jfrog-cli-linux-386/jfrog?bt_package=jfrog-cli-linux-386 \
    && chmod a+x /usr/bin/jfrog

(Click Here for Reference Link)