0

I'm working with docker at the moment and I'm trying to run a command from rc.local in the Dockerfile but the command doesn't exit unless I kill it manually. Is there a way I can "disown" the process so that I can get to shell and still have the process running by itself?

The command I'm working with is free radius -X -l /var/log/radius.log is there a way to maybe add this as a service running in the background?

Any help is appreciated!

  • <command> & will put the command to the background. If you also want to run the command even if you close the terminal/log out, run nohup <command> &. But in the latter case, you will have to kill the process manually anyway. – ridgy Mar 8 '17 at 14:25
  • @ridgy This command works but only when I run it manually from bash, the dockerfile doesn't seem to run the command by itself causing the service to never start... – jamieg Mar 9 '17 at 15:36
  • 1
    Ok, I read the question again. I'm not sure but suppose your command is radiusd -X -l .... The option -X is equal to -sfxx -l stdout (see manpage), where -smeans "single server", -xx means "print details to stdout", and -fmeans " Do not fork, stay running as a foreground process". The last option keeps radiusd from detaching, and thus should only be used when run manually, because otherwise rc.localwon't continue. If you want more debug information, -sxxmight work, but you probably have to redirect stdout (I don't know if -xx respects -l). – ridgy Mar 9 '17 at 15:55
  • You can also debug an already running radiusd with raddebug – ridgy Mar 9 '17 at 15:59
  • I've solved my issue: Rather than using this CMD freeradius -X -l /var/log/radius.log & I used: CMD freeradius -X -l /var/log/radius.log & \ bash This seemed to work, also using a shell script to run the command worked fine also. I'll look into why docker could't run the command when the container runs but running from the shell was fine... – jamieg Mar 10 '17 at 10:40
0

As mentioned by ridgy you can specify & after your command to drop it into the background. For my particular case this didn't work. NOTE using & needs to go in hand with bg so that the process can run in the background the same goes for using ctrl-z to set a background process.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.