cannot run jfrog executable from inside alpine linux container
Clash Royale CLAN TAG#URR8PPP
cannot run jfrog executable from inside alpine linux container
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.
alpine linux
python:3.4-alpine
openjdk:8-jdk-alpine
Not Found
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
python:3.4-alpine
jfrog
curl
jfrog
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/ash
bin/sh jfrog
/ # 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.
updated the question
– LetsPlayYahtzee
Apr 4 '17 at 14:31
4 Answers
4
I'm not sure but the jfrog executable is dynamically linked, and with ldd jfrog
you get :
ldd jfrog
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
apk add libc6-compat
nope :/ i think I will have to use curl instead of
jfrog
– LetsPlayYahtzee
Apr 4 '17 at 15:04
jfrog
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"]
I got an error about "You are not currently on a branch." when trying to use that dockerfile
– rwilson04
Dec 21 '17 at 22:37
Had to use
RUN GOOS=linux go get github.com/jfrogdev/jfrog-cli-go/jfrog-cli/jfrog
instead– rwilson04
Dec 21 '17 at 23:01
RUN GOOS=linux go get github.com/jfrogdev/jfrog-cli-go/jfrog-cli/jfrog
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.
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 4 '17 at 15:01
jfrog
ubuntu
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)
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
I think we need more details. Please see stackoverflow.com/help/mcve
– BMitch
Apr 4 '17 at 14:23