Docker: can’t run some services using /etc/init.d/script ,”-x” flag in bash

I build a docker image, everything runs well on my dev machine. But when i deploy the images to my other machine, some services in the container was not able to start.

The services starts by using /etc/init.d/script , when i troubleshoot the script i see the script stop at this command

test -x $DAEMON && test -f /etc/postfix/main.cf || exit 0

Not sure what “test -x ” is , i google and found that : -x is the same as setting xtrace with the -o option to bash.

So it gave me some hints to find where the root cause, it looks like we can’t run xtrace , i re-run my container with this option to enable xtrace

sudo docker run -d --cap-add=SYS_PTRACE --security-opt seccomp=unconfined --rm image_name
Then it works

Leave a Reply

Your email address will not be published. Required fields are marked *