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!

jamieg
  • 80
  • 2
  • 10
  • ` &` 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 &`. But in the latter case, you will have to kill the process manually anyway. – ridgy Mar 08 '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 09 '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 `-s`means "single server", `-xx` means "print details to stdout", and `-f`means " 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.local`won't continue. If you want more debug information, `-sxx`might work, but you probably have to redirect stdout (I don't know if `-xx` respects `-l`). – ridgy Mar 09 '17 at 15:55
  • You can also debug an already running radiusd with [raddebug](http://freeradius.org/radiusd/man/raddebug.html) – ridgy Mar 09 '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

1 Answers1

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.

jamieg
  • 80
  • 2
  • 10