How to get docker commands to run in the background with nohup
From the docker exec documentation page https://docs.docker.com/engine/reference/commandline/exec/
--interactive , -i Keep STDIN open even if not attached
--tty , -t Allocate a pseudo-TTY
I guess removing both the -i
and -t
flags would probably be sufficient
nohup service inside docker container
Skip all the effort to nohup and background, instead just detach from the process (note the -d
):
sudo docker exec -itd php7-fpm bash -c 'php /www/site/artisan queue:listen'
shell script to execute a nohup task inside a docker
The below way of scripting works for me!!!!!!!!!
ex=' /opt/kafka/bin/connect-standalone.sh /opt/kafka/config/connect-standalone-mongo.properties /opt/kafka/config/connect-mongo-sink.properties > /opt/kafka/kafka-mongo-info.out 2> /opt/kafka/kafka-mongo-error.err &'
while true
do
# nohup $ex 1> nohup_kms.out 2> nohup_kms.err | tee -a /var/log/my_uber_script.log
# nohup $ex 1> nohup_kms.out 2> nohup_kms.err
done
you can try any one inside the loop
Not able to start 2 tasks using Dockerfile CMD
One process inside docker container has to run not in background mode, because docker container is running while main process inside it is running.
The /scripts/entryPoint.sh
should be:
#!/bin/bash
nohup /bin/bash -c "http-server -p 80 /ui" &
nohup /bin/bash -c "mb --port 2525 --configfile /mb/imposters.ejs --allowInjection"
Everything else is fine in your Dockerfile
.
Commands to execute background process in Docker CMD
Besides the comments on your question that already pointed out a few things about Docker best practices you could anyway start a background process from within your start.sh
script and keep that start.sh
script itself in foreground using the nohup
command and the ampersand (&
). I did not try it with mongod
but something like the following in your start.sh
script could work:
#!/bin/sh
...
nohup sh -c mongod --dbpath /test &
...
Related Topics
How to Move First Column to Last Column in Unix
Print the Directory Where the 'Find' Linux Command Finds a Match
How to Increase Openfabrics Memory Limit for Torque Jobs
Perf Top Result About Nested Functions
How to Extract Patterns Form a Text Files in Shell Bash
File Glob Patterns in Linux Terminal
Webpack Build Fails with Gitlab-Ci
How to Make My .Bat File Run Linux Command to Remote Linux
Qserialport Cannot Open Tty After Application Has Previously Been Run by 'Root'
How to Display Filename from a Column Using Awk
Find the Average of Fields in the Columns
Calling Printf from Assembly Language on 64Bit and 32Bit Architecture Using Nasm
Why Does This Shell Pipeline Exit
Linux Script- Date Manipulations
Resolve Relative Relocations in Partial Link