D
D
Dmitry Chizhov2017-06-12 17:08:17
Laravel
Dmitry Chizhov, 2017-06-12 17:08:17

Executing a command when starting a Docker container?

Something is completely off. You need to clear the laravel cache when starting the container. But the problem is that the cache cleaning script ends and the container ends with it. I tried to sculpt crutches like:


CMD ["/usr/bin/php", "/var/www/laravel/artisan", "cache:clear"]
CMD ["/usr/sbin/apache2ctl", "-D", "FOREGROUND"]


ENTRYPOINT [ "/bin/bash", "-c", "'php /var/www/laravel/artisan cache:clear'", "&&", "/usr/sbin/apache2ctl", "-D", " FOREGROUND"]


CMD ["/var/www/laravel/artisan", "cache:clear", "&&", "/bin/bash"]

And a million more combinations, but nothing helps. At best, it removes the layer with this command:

Step 11/12 : CMD /usr/bin/php /var/www/laravel/artisan cache:clear
---> Running in 4c1202595b35
---> 5dff8f60522c
Removing intermediate container 4c1202595b35

Deletes why? what am I doing wrong? Please help me figure it out .
PS
Initially, the problem is that the withoutOverlapping() method of the task cron, which protects the queue task from overlapping, is stored in the cache for a day and does not start cron tasks when the container is restarted / recreated. reads in the cache that it is already running. Maybe there are other ways to solve the problem?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
rustler2000, 2017-06-12
@rustler2000

Use --rm and run without cache. The container must be disposed of in the trash after use.
Well, or smut smut entry point.sh again smut and at the end --rm anyway.

D
Dmitry Chizhov, 2017-06-12
@Catsys2

CMD /bin/bash -c '/usr/bin/php /var/www/laravel/artisan cache:clear' && /usr/sbin/apache2ctl -D FOREGROUND

This crutch helped. Removing the layer seems to be normal. because no changes happened (only project files changed that are not part of the image) docker slammed the layer.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question