Morten
Morten

Reputation: 199

Docker `/bin/sh: 1: [<executable>, : not found`

I want to run an executable installed with pip. Running the following image gives me /bin/sh: 1: [hbd,: not found:

FROM python:3.8.3-slim-buster

WORKDIR /data

COPY cookies.txt /data/cookies.txt

RUN python3.8 -m pip install humblebundle-downloader

CMD ["hbd", "download", "--cookie-file", "/data/cookies.txt", "--library-path", "/data" "--progress", "--update"]

I've tried CMD ["/usr/local/bin/python3.8", "-m", "hbd", "download",... and CMD python -m hbd download... and similar as well. Resulting in /bin/sh: 1: [/usr/local/bin/python3.8,: not found etc.

If I replace CMD ... with CMD which python3.8 && which hbd && find / -executable -type f -name hbd I get:

/usr/local/bin/python3.8
/usr/local/bin/hbd
/usr/local/bin/hbd

Which to me, tells me that the executables are there!?

How do I execute the, clearly present, executable?

I'm at my wits' end. Thank you!

Edit: I tried with the 'non-slim' version of the base image, i.e FROM python:3.8.5-buster, no dice.

Upvotes: 0

Views: 4796

Answers (3)

Uku Loskit
Uku Loskit

Reputation: 42030

CMD ["hbd", "download", "--cookie-file", "/data/cookies.txt", "--library-path", "/data" "--progress", "--update"]

Should be

CMD ["hbd", "download", "--cookie-file", "/data/cookies.txt", "--library-path", "/data", "--progress", "--update"]

What I think is happening is that since CMD is not specified as a valid JSON array, it is interpreted as a normal command that begins with [ which is of course not valid.

Upvotes: 1

Nicolas Bousquet
Nicolas Bousquet

Reputation: 4000

Hello I trying your Dockerfile it failed, I ran a shell inside the instead and tried hbd, the command was available just fine:

docker run -ti 7552b04ea25b sh
# hbd
usage: hbd [-h] {download} ...
hbd: error: the following arguments are required: action

I then tried without the quote, square brackets and commas, it worked:

CMD hbd download --cookie-file /data/cookies.txt --library-path /data --progress --update

I tried again with your CMD, it failed, I shortened it, it worked, with a few trial and errors I finally I saw that you forgot a comma between 2 arguments. You command shall be (notice the comma between 2 arguments has been added):

CMD ["hbd", "download", "--cookie-file", "/data/cookies.txt", "--library-path", "/data", "--progress", "--update"]

So next time, try you hypothesis and try to investigate yourself:

Hypothesis: The executable is not found ? Then test it by checking the command inside the container by running a shell inside it. Conclusion: path & executable are found.

Hypothesis: CMD syntax is wrong ? Let's try a different syntax. It works with CMD hbd. So yes obvious that was the CMD syntax... Let's try to debug it and craft it by dichotomy... Hey a comma is missing ;) Problem solved.

Upvotes: 1

coder here
coder here

Reputation: 189

The issue might be because of which the environment variables are not set or the path is not exported to the environment. Trying either of these, might help

Upvotes: 0

Related Questions