You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Using "docker run --init" with arguments to tini #215
using tini directly in the dockerfile works well so far.
However, ideally I would like it to be transparent, so that the dockerfile does not have to be changed
Using "docker run --init" works, but then I cannot add flags to the tini call.
Is there any way to do it?
docker run --init --entrypoint docker-init test -g -s -- <fill with your CMD>
test.sh && sh trap.sh"
Explanation:
by adding --init the docker-init binary is added to the container (I don't know how, there's a vague description here)
--entrypoint only accepts one "word", so we need to add all the parameters we want from tini to the command in the end. This includes all the -g -s -- ...
given the previous point, we are overwriting the image's CMD, so we need to explicitly add all of the commands there again, making it very little ergonomic since we need to gather the same commands from the Dockerfile
the -s option is added given that (for a reason I don't know) specifying the --entrypoint doesn't assign PID 1, so we need to handle zombie processes with the -s option. More on that here
The current docker documentation about run --entrypoint actually gives an example like that.
We can obtain the same result with --entrypoint '' image-name docker-init -g -s -- cmd
In either case, it actually runs docker-init twice! i.e. /sbin/docker-init -- docker-init -g -s -- /test.sh
Thankfully, tini's behavior can also be controlled with environment variables, so I think for now the proper way if all you want is passing the -g option is to do: run --init --env TINI_KILL_PROCESS_GROUP=1
Activity
AgustinRamiroDiaz commentedon Feb 18, 2024
I think this is something that should be proposed to the docker community, I'm not sure that @krallin has the decision on this
AgustinRamiroDiaz commentedon Feb 18, 2024
I've found a way to do it, but it's not ergonomic
Explanation:
--initthedocker-initbinary is added to the container (I don't know how, there's a vague description here)--entrypointonly accepts one "word", so we need to add all the parameters we want fromtinito the command in the end. This includes all the-g -s -- ...CMD, so we need to explicitly add all of the commands there again, making it very little ergonomic since we need to gather the same commands from theDockerfile-soption is added given that (for a reason I don't know) specifying the--entrypointdoesn't assign PID 1, so we need to handle zombie processes with the-soption. More on that herejohan-boule commentedon Aug 10, 2024
The current docker documentation about
run --entrypointactually gives an example like that.We can obtain the same result with
--entrypoint '' image-name docker-init -g -s -- cmdIn either case, it actually runs docker-init twice! i.e.
/sbin/docker-init -- docker-init -g -s -- /test.shThankfully,
tini's behavior can also be controlled with environment variables, so I think for now the proper way if all you want is passing the-goption is to do:run --init --env TINI_KILL_PROCESS_GROUP=1