Docker launches the top access point with a shell script that takes arguments

I have a shell script access point that takes the arguments -a -b .

I have a docker-compose.yml file where I redefine the tomcat entry point with the instruction:

entrypoint: /usr/local/tomcat/entrypoint.sh -a param1 -b param2 

What is the docker run option ?

 docker run --entrypoint "/usr/local/tomcat/entrypoint.sh -a param1 -b param2" tomcat:jre8 

does not work

I get:

 docker: Error response from daemon: invalid header field value "oci runtime error: container_linux.go:247: starting container process caused \"exec: \\\"/usr/local/tomcat/entrypoint.sh -a param1 -b param2\\\": stat /usr/local/tomcat/entrypoint.sh -a param1 -b param2: no such file or directory\"\n". 

FYI:

 docker run --entrypoint "/usr/local/tomcat/entrypoint.sh" tomcat:jre8 

works from a docker point of view but obviously the script fails

+5
source share
3 answers

This is because of the quotes you use around your team.

When launching docker run --entrypoint "/usr/local/tomcat/entrypoint.sh -a param1 -b param2" tomcat:jre8 Docker treats everything inside these quotes as a single script file.

As you can see from this error:

 stat /usr/local/tomcat/entrypoint.sh -a param1 -b param2: no such file or directory\"\n". 

It tries to execute stat in the file before running, so it knows if it exists.

Put the arguments at your entry point at the end of the docker command as follows:

 docker run --entrypoint <entrypoint.sh> <image:tag> <arg1> <arg2> <arg3> 

Your team will:

 docker run --entrypoint /usr/local/tomcat/entrypoint.sh tomcat:jre8 -a param1 -b param2 

Take a look at the code snippets in the official documentation:

ENTRYPOINT of an image is similar to COMMAND because it indicates which executable is launched when the container starts

https://docs.docker.com/engine/reference/run/#/entrypoint-default-command-to-execute-at-runtime

+8
source

I think this is also worth noting:

If you have tons of arguments for your docker run , your --entrypoint should be the first.

I don’t know which of my arguments was the problem, but adding --entrypoint "/bin/bash" to the end did not prevent ENTRYPOINT from the Docker file from executing. My arguments included:

  • 1x --rm
  • 1x --name
  • 1x -it
  • 3x -v
  • 6x -p
  • 4x -e
+2
source

I'm not sure that you can do this in accordance with the official docker documentation:

Note. You can override the ENTRYPOINT setting with --entrypoint, but this can only set the binary for exec (no sh -c will be used).

https://docs.docker.com/engine/reference/builder/#/environment-replacement

0
source

Source: https://habr.com/ru/post/1262923/


All Articles