Answer the question
In order to leave comments, you need to log in
How to run php script in background after container start?
Hello.
There is a script that should constantly run in the background, how to run it?
Script
#!/bin/sh
set -e
nohup php /var/www/project/script.php >/dev/null 2>&1 &
COPY start.sh /home/user
RUN chmod +x /home/user/start.sh
CMD bash -C '/home/user/start.sh';'bash'
COPY start.sh /home/user
RUN chmod +x /home/user/start.sh
ENTRYPOINT ["/home/user/start.sh"]
CMD bash -C 'nohup php /var/www/project/script.php >/dev/null 2>&1 &';'bash'
Answer the question
In order to leave comments, you need to log in
in the background in a container? What for?
you can just run php /var/www/project/script.php
and let this script run in the container.
If you need a shell to a container usedocker exec -it container_name bash
I can advise supervisord.org for such a case.
An example from a personal config. The script starts when the container is started. You can enable auto restart.
[program:startup]
command=/opt/startup.sh
startretries=0
autostart=true
autorestart=false
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question