Default Docker entrypoint

I am creating an image from another image that sets a specific entry point. However, I want my image to have a default value. How to reset ENTRYPOINT?

I tried the following Docker file:

FROM some-image ENTRYPOINT ["/bin/sh", "-c"] 

Unfortunately, it does not work as the default entry point, since it needs a quotation mark for the command.

 docker run myimage ls -l / # "-l /" arguments are ignored file1 file2 file3 # files in current working directory docker run myimage "ls -l /" # works correctly 

How to use commands without quoting?

+5
source share
1 answer

To disable an existing ENTRYPOINT , set an empty array to the ENTRYPOINT file

 ENTRYPOINT [] 

Then your arguments in docker run will execute as usual.

The reason your ENTRYPOINT ["/bin/sh", "-c"] requires quoted lines is because without quotes, ls arguments are passed instead of sh .

Unspecified results with a large number of arguments sent to sh

 "/bin/sh", "-c", "ls", "-l", "/" 

Quoting allows you to pass the full command ( sh -c ) to sh as a single argument.

 "/bin/sh", "-c", "ls -l /" 
+20
source

All Articles