Open muhamadazmy opened 1 year ago
Nice ideas here to improve the image definitions and provide some style guidance for new contributions.
Generally I agree, but one question: why bother with exporting a generic PATH
before starting sshd
?
New ssh sessions are going to source default profile
provided with the shell in any container image I've seen, thus providing the same outcome of generic PATH
in the environment.
I noticed that many of the zinit config files (for services) does this weird thing as follows
I don't know why this is a pattern, why do u need bash to run a single command with arguments. This instead should become
For example the peertube flist contains this file ssh.yaml that looks like this
which can perfectly become
Okay, I hope you know what the different is between the two, but I will explain anyway. When u use bash, zinit will start a bash process, that then will run this script and then run the command. Now instead of have 1 process running, we end up with 2 processes running (forever)
When you check the process tree you will see something like
While if u use the correct way of executing a single command you will see
Now, when to use bash? You can ONLY use bash if you want to run some actual BASH code. in that case it becomes acceptable. It's also HIGHELY recommended that you do
exec
of your last command (your long running process) at the end of the script.For example, this is the standard ssh.yaml I use in my images
I here use the bash but see what I do.
/usr/sbin/sshd -D
directly I doexec /usr/sbin/sshd -D
what exec does (checkman exec
for more) is that it transfor the current process into sshd. in other wordsbash
process sieze to exist and instead it becomse bash. So after running this if you try to check the process tree it will look likelog: stdout
makes sure that sshd logs actually go to zinit stdout which will make it endup in zos vm logs not in the ring buffer of zinit (hence you can't see it with zinit log but can help debugging a problem if u can't ssh to the node)So what to do: