Outputs the equivalent argv of what you would get with a docker run
command.
This considers the given image's CMD
, ENTRYPOINT
, and docker run
's --entrypoint
flag.
$ run hello-world@sha256:96ebeec770e1af26469c98913277e1c3b40933202ca398cefc16177c3f26cc75
["cmd","/C","type C:\\hello.txt"]
$ run --entrypoint /crane hello-world@sha256:96ebeec770e1af26469c98913277e1c3b40933202ca398cefc16177c3f26cc75
["/crane"]
$ run hello-world@sha256:96ebeec770e1af26469c98913277e1c3b40933202ca398cefc16177c3f26cc75 crane
["crane"]
$ run gcr.io/go-containerregistry/crane version
["/ko-app/crane","version"]
$ run --entrypoint '["crane", "ls"]' gcr.io/go-containerregistry/crane ubuntu
["crane","ls","ubuntu"]
Here's an alternative way of dissecting the behavior that might also be helpful for others:
printargs
Dockerfile
Build an image called
printargs
:Then run variations of it...
printargs
plus its options and append options from CMD)But here's the one that might surprise you! 🤯
It's not
4 5 6
as you might have expected. Once you override the entrypoint, it's likely the rationale is that you're expected to supply optional arguments as well (it makes sense that once you replace the entrypoint, the default CMD options are probably no longer appropriate to use, so they're ignored).