Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Override docker entrypoint with spaces

I'm trying to override the docker entrypoint using docker run. This works in docker-compose:

  myapp:
    build: .
    security_opt:
      - seccomp:unconfined
    entrypoint: dlv debug local/myorg/myapp -l 0.0.0.0:2345 --headless=true --log=true --server
    volumes:

Using:

docker run --entrypoint "dlv debug local/myorg/myapp -l 0.0.0.0:2345 --headless=true --log=true --server"

Results in:

exec: \"dlv debug local/myorg/myapp -l 0.0.0.0:2345 --headless=true --log=true --se
rver\": stat dlv debug local/myorg/myapp -l 0.0.0.0:2345 --headless=true --log=true --server: no such file or directory
like image 463
Flynn Handley Avatar asked Dec 23 '22 07:12

Flynn Handley


2 Answers

Check the article "How to properly override the ENTRYPOINT using docker run" by Adrian Oprea.

The documentation clearly states that the ENTRYPOINT only specifies the executable to run, when the container starts.

There is something a bit counter-intuitive here and if you take a good look at the example commands on the documentation page, you’ll see that the arguments are being passed after the image name.

In your case:

 docker run --entrypoint dlv YOUR_IMAGE_NAME debug local/myorg/myapp -l 0.0.0.0:2345 --headless=true --log=true --server
                             ^^^^^^^^^^^^^^^
like image 74
VonC Avatar answered Dec 28 '22 09:12

VonC


Extending @VonC's answer in a bit simpler way, I had to override my ENTRYPOINT with npm start because I mistakenly wrote ENTRYPOINT ["ng","serve"] at the end and it was throwing error

docker: Error response from daemon: OCI runtime create failed: container_linux.go:367: starting container process caused: exec: "ng": executable file not found in $PATH: unknown.

That clearly meant that ng was not added to $PATH environment variable.

So I had to override my ENTRYPOINT instruction to ENTRYPOINT ["npm","start"] and due to that space in between npm and start I wasn't able to run it easily

So as suggested by @VonC's answer, you can pass arguments after the image name like

docker run -p 4200:4200 --entrypoint npm ihamzakhanzada/angular-app:1.1 start

Where ihamzakhanzada/angular-app:1.1 is the name of the image.

like image 32
Hamza Khanzada Avatar answered Dec 28 '22 09:12

Hamza Khanzada