B
B
bio2017-03-30 13:05:25
PHP
bio, 2017-03-30 13:05:25

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 &

Tried
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'

Nothing works, the container does not start, there are no errors in the logs.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrey Burov, 2017-03-30
@BuriK666

in the background in a container? What for?
you can just run php /var/www/project/script.phpand let this script run in the container.
If you need a shell to a container usedocker exec -it container_name bash

P
Pavel Malitov, 2017-03-30
@Tenskwatawa

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 question

Ask a Question

731 491 924 answers to any question