当前位置: 动力学知识库 > 问答 > 编程问答 >

php - How to insert dockerised cron process in a docker-compose built LEMP stack?

问题描述:

I have a LEMP stack which is built by this docker-compose file:

cadvisor:

image: google/cadvisor:latest

container_name: lemp_cadvisor

ports:

- "8080:8080"

volumes:

- "/:/rootfs:ro"

- "/var/run:/var/run:rw"

- "/sys:/sys:ro"

- "/var/lib/docker/:/var/lib/docker:ro"

base:

build: ./base

container_name: lemp_base

volumes:

- /home/core/server-lemp/www/:/var/www/:rw

phpmyadmin:

build: ./phpmyadmin

container_name: lemp_phpmyadmin

links:

- base

volumes:

- /var/www/phpmyadmin

- ./phpmyadmin/var/www/phpmyadmin/config.inc.php:/var/www/phpmyadmin/config.inc.php:rw

mariadb:

build: ./mariadb

container_name: lemp_mariadb

environment:

- MYSQL_ROOT_PASSWORD=pwd

links:

- base

volumes:

- /var/run/mysqld

- /home/core/server-lemp/mariadb/:/var/lib/mysql/:rw

- ./mariadb/etc/mysql/my.cnf:/etc/mysql/my.cnf:ro

ffmpeg:

build: ./ffmpeg

container_name: lemp_ffmpeg

links:

- base

volumes:

- /usr/ffmpeg

cron:

build: ./cron

container_name: lemp_cron

links:

- base

volumes:

- /etc/cron.weekly

- /etc/cron.d

- /etc/cron.hourly

- /etc/cron.daily

- /etc/cron.monthly

php:

build: ./php

container_name: lemp_php

links:

- base

volumes:

- /var/run/php-fpm

- ./php/usr/local/php7/etc/php-fpm.conf:/usr/local/php7/etc/php-fpm.conf:ro

- ./php/usr/local/php7/etc/php.ini:/usr/local/php7/etc/php.ini:ro

- ./php/usr/local/php7/etc/php-fpm.d/www.conf:/usr/local/php7/etc/php-fpm.d/www.conf:ro

volumes_from:

- base

- phpmyadmin

- mariadb

- ffmpeg

- cron

nginx:

build: ./nginx

container_name: lemp_nginx

links:

- base

ports:

- "80:80"

- "443:443"

volumes:

- /var/cache/nginx

- ./nginx/etc/nginx/nginx.conf:/etc/nginx/nginx.conf:ro

volumes_from:

- php

My ./cron/Dockerfile looks like this:

# Lanti/lempCron

#

# VERSION 1.0.0

FROM lemp_base:latest

MAINTAINER XY <[email protected]>

LABEL Description="Cron" Vendor="XY" Version="1.0"

RUN apt-get -y update && apt-get -y dist-upgrade \

&& apt-get -y install \

cron

RUN rm -rf /var/lib/apt/lists/*

CMD ["cron", "-f"]

When in a Wordpress install I inspecting running cron jobs with WP Crontrol plugin, I got the following error message:

There was a problem spawning a call to the WP-Cron system on your site.

This means WP-Cron events on your site may not work. The problem was:

Failed to connect to 127.0.0.1 port 80: Connection refused

I assume because of the same error that causing this, the Cache Purge option in the Nginx-helper plugin also not working.

网友答案:

Wordpress is presumably running in your 'php' container, and the "wp-cron" function is presumably working there. Although it is "cron-like", it is actually part of Wordpress.

You have defined no ports for your `php' container, so it appears that you need to update your Docker networking so that wp-contain can access port 80 on the correct host.

分享给朋友:
您可能感兴趣的文章:
随机阅读: