Docker Entry Point with Script Arguments
Dockerfile we can define entry point as below :-
From Wildfly ENTRYPOINT["/opt/jboss/wildfly/bin/standalone.sh", "-b", "0.0.0.0"]
But i want to pass entry point while we start the container with some argument as below :-
docker run -it --entrypoint /opt/jboss/wildfly/bin/standalone.sh -Ddb_driver=mysql -b 0.0.0.0 -Duser=root Wildfly
but its not working because docker try to evaluate script argument (-D and -b) as docker command parameter. I gave entrypoint in quote as well but its not working.
How can i pass script argument in docker entrypoint?
One Solution collect form web for “Docker Entry Point with Script Arguments”
--entrypoint only allows to specify a single string which is interpreted as name/path of the binary to start. This is different from what you can specify in the Dockerfile, as it allows to specify json arrays.
ENTRYPOINT in Dockerfiles actually serves a different purpose then what you are using it for.
ENTRYPOINT should only specify the entry binary to call, while
CMD specifies the arguments to that binary. If there is no
CMD becomes the entrypoint while also containing the arguments.
This should work for you:
ENTRYPOINT ["/opt/jboss/wildfly/bin/standalone.sh"] CMD ["-b", "0.0.0.0"]
docker run is called without arguments now, it will use the value of
CMD as arguments to the entrypoint. When it is called with arguments, the specified arguments are appended to the entrypoint instead of what was defined in
CMD. For example:
docker run -it Wildfly -Ddb_driver=mysql -b 0.0.0.0 -Duser=root
/opt/jboss/wildfly/bin/standalone.sh -Ddb_driver=mysql -b 0.0.0.0 -Duser=root