我有一个由这个docker-compose文件构建的LEMP堆栈:
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
我的./cron/Dockerfile
看起来像这样:
# 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"]
在Wordpress安装中,我使用WP Crontrol插件检查正在运行的cron作业时,收到以下错误消息:
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
我假设因为导致这个的相同错误,Nginx-helper插件中的Cache Purge选项也无法正常工作。
Wordpress可能在你的'php'容器中运行,而“wp-cron”函数可能在那里工作。虽然它是“类似cron”,但它实际上是Wordpress的一部分。
你已经为你的'php'容器定义了没有ports,所以看起来你需要更新你的Docker networking,以便wp-contains可以访问正确主机上的端口80。