6

Trying to figure out why my dockerfile:

FROM mcr.microsoft.com/powershell:ubuntu-focal
RUN apt-get -qq -y update && \
    apt-get -qq -y upgrade && \
    apt-get -qq -y install curl ca-certificates python3-pip exiftool mkvtoolnix
RUN pip3 install gallery-dl yt-dlp
WORKDIR /mydir
COPY gallery-dl.ps1 .
ENTRYPOINT ["gallery-dl.ps1"]

throws the following error when run:

> docker build --file gallery-dl.dockerfile --tag psa .
> docker run -it --rm --name psatest psa
docker: Error response from daemon: failed to create shim: OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "gallery-dl.ps1": executable file not found in $PATH: unknown.

I've tried seemingly everything: using CMD instead of ENTRYPOINT, modifying the COPY dest to ./gallery-dl.ps1, changing the order of commands. I've prepended #!/usr/bin/pwsh -File to the ps1 script (as instructed in a different question of mine). When I attach into the container and ls it shows all of my mounts and gallery-dl.ps itself where it should be and where I'm supposedly calling it:

PS /mydir> ls
conf  gallery-dl.ps1  output

The only thing that works is removing WORKDIR but I actually need that, I can't just run everything in root.

1 Answer 1

7

Two things: Make sure the file is marked as executable. And since /mydir isn't in your path, you need to tell Docker to look for the script in the current directory by adding ./ in front of the name.

FROM mcr.microsoft.com/powershell:ubuntu-focal
RUN apt-get -qq -y update && \
    apt-get -qq -y upgrade && \
    apt-get -qq -y install curl ca-certificates python3-pip exiftool mkvtoolnix
RUN pip3 install gallery-dl yt-dlp
WORKDIR /mydir
COPY gallery-dl.ps1 .
RUN chmod +x gallery-dl.ps1
ENTRYPOINT ["./gallery-dl.ps1"]
Sign up to request clarification or add additional context in comments.

2 Comments

Oh my God, it was the ./ bit. Thank you, I struggled with this so much haha. I don't need to prepend that bit on Windows, but I guess it's required on Linux.
Yes, Linux only looks in the PATH directories for executables unlike Windows which also looks in the current directory.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.