Docker entrypoint can't find file

docker entrypointsh
docker-compose entrypoint
docker run option
docker add vs copy
docker build and run
docker cmd run shell script
docker entrypoint script example
docker entrypoint and cmd together

I have a very simple docker build file:

FROM openjdk:10

ENV JENAVERSION=3.7.0

RUN mkdir /fuseki

RUN wget http://apache.claz.org/jena/binaries/apache-jena-fuseki-$JENAVERSION.tar.gz -P /tmp \
    && tar -zxvf /tmp/apache-jena-fuseki-$JENAVERSION.tar.gz -C /tmp \
    && mv -v /tmp/apache-jena-fuseki-$JENAVERSION/* /fuseki

EXPOSE 3030

ENTRYPOINT ["/bin/bash", "/fuseki/fuseki-server"]

I've tried different variations on CMD and ENTRYPOINT, but nothing allows "fuseki-server" to execute. Always a "No such file or directory" error. If I manually create an empty container from openjdk:10, and execute each command manually, it works fine. What's going on?

If I build and run your Dockerfile, I get a different error from what you've described. I see:

Can't find jarfile to run

If you look at the fuseki-server shell script, it's trying to find the jar file relative either to your current directory or to the $FUSEKI_HOME environment variable:

export FUSEKI_HOME="${FUSEKI_HOME:-$PWD}"

if [ ! -e "$FUSEKI_HOME" ]
then
    echo "$FUSEKI_HOME does not exist" 1>&2
    exit 1
    fi

JAR1="$FUSEKI_HOME/fuseki-server.jar"
JAR2="$FUSEKI_HOME/jena-fuseki-server-*.jar"
JAR=""

So if you set the FUSEKI_HOME environment variable in your Dockerfile:

ENV FUSEKI_HOME=/fuseki

Then the container starts up without errors:

[2018-06-04 14:02:17] Server     INFO  Apache Jena Fuseki 3.7.0
[2018-06-04 14:02:17] Config     INFO  FUSEKI_HOME=/fuseki
[2018-06-04 14:02:17] Config     INFO  FUSEKI_BASE=/run
[2018-06-04 14:02:17] Config     INFO  Shiro file: file:///run/shiro.ini
[2018-06-04 14:02:18] Server     INFO  Started 2018/06/04 14:02:18 UTC on port 3030

Dockerfile reference, docker build -<<EOF FROM busybox RUN echo "hello world" EOF. You can substitute the examples with your preferred approach, or the approach that best fits  Docker ENTRYPOINT and CMD can have two forms: Shell form; Exec form; The syntax for any command in shell form is: <instruction> <command> The syntax for instructions in exec form is: <instruction> [“executable”, “parameter”] You can write Docker CMD/ENTRYPOINT instructions in both forms: CMD echo “Hello World” (shell form)

I think the issue is the line ending - the entrypoint needs to have LF line ending. I get the same error when my entrypoint has CLRF line ending.

Best practices for writing Dockerfiles, How do I initialize/seed data into my container at runtime, before the daemon process Use a shell script as the ENTRYPOINT of a container, and execute the​  With the ENTRYPOINT instruction, it is not possible to override the instruction during the docker run command execution like we are with CMD. This highlights another usage of ENTRYPOINT , as a method of ensuring that a specific command is executed when the container in question is started regardless of attempts to override the ENTRYPOINT .

Wow... After going through @larsk's suggestion it occurred to me to change the entrypoint to

ENTRYPOINT ["tail", "-f", "/dev/null"] 

and go into the container to see what was actually there. It turns out that I was accidently overwriting the /fuseki folder with a volume declaration in the compose file I was using. (facepalm...)

Docker run reference, You can connect multiple containers using user-defined networks and shared volumes. The container's main process is responsible for managing all processes​  ENTRYPOINT ["executable", "param1", "param2"] Using this syntax, Docker will not use a command shell, which means that normal shell processing does not happen. If you need shell processing features, then you can start the JSON array with the shell command.

How to use an entrypoint script to initialize container data at , Docker will run the container and the hostname command instead of the CMD's echo command. You can see this in the output. You can see that when the container starts up, the command portion is interprated to be sh -c 'docker-entrypoint.sh postgres'. The script is invoked and given the argument postgres . The script checks if the first argument sent to it is equal to the string postgres , and if so, executes a series of instructions to set up a database.

Run multiple services in a container, ENTRYPOINT is Also Overridable. We can easily override the ENTRYPOINT declared in a Dockerfile as well. To do so, we specify the --entrypoint  Or, you can pass the ab command with the http endpoint at the end of the docker run command. Here is the key difference between CMD and ENTRYPOINT Using CMD: Just add the full ab command at the end of the docker run command.

Docker CMD VS Entrypoint commands: What's the difference?, You could package everything in a Docker image with an ENTRYPOINT referencing your script. Now the user can simply docker run your image  CMD sets default command and/or parameters, which can be overwritten from command line when docker container runs. ENTRYPOINT configures a container that will run as an executable. If it doesn’t make much sense or you after details, then read on. Docker images and layers. When Docker runs a container, it runs an image inside it.

Comments
  • That's really weird. The package actually includes three ways to start the server, a .jar file (fuseki-server.jar), a bash script (fuseki-server) and a .war file (fuseki-server.war) I'm trying to run the plain script and getting "/fuseki/fuseki-server: No such file or directory". I don't know why it would be jumping you right to the .jar file.