linux - PID of processes in docker container when run commands via && -
i wrote dockerfile , use cmd ["/bin/bash", "-c", "script1.sh && script2.sh" start container.
after running container, found process pid 1 process cmd column bash, , script2.sh child process.
f s uid pid ppid c pri ni addr sz wchan tty time cmd 4 s 0 1 0 0 80 0 - 4491 wait ? 00:00:00 bash 0 s 0 8 1 0 80 0 - 4494 wait ? 00:00:00 script2 0 s 0 10 8 99 80 0 - 1632452 futex_ ? 00:01:05 java 4 s 0 64 0 0 80 0 - 4545 wait ? 00:00:00 bash 0 r 0 79 64 0 80 0 - 1785 - ? 00:00:00 ps if use cmd [ "/bin/bash", "-c", "script2.sh" ], process pid 1 script2.sh.
could explain happen in first case?
in both cases, bash starts out pid 1.
for first example, bash going run command "script1.sh && script2.sh", first invoking subshell execute script1.sh, subshell execute script2.sh if script1.sh , subshell exited without errors. full output (i.e. ps -ef) show command /bin/bash -c "script1.sh && script2.sh".
for second example, bash running single command, , execs command. no subshell needed, , script2.sh can replace , becomes pid 1.
Comments
Post a Comment