无法在Wordpress容器中使用file_get_contents访问本地主机

时间:2019-08-09 16:19:45

标签: wordpress docker docker-compose localhost

使用docker compose运行Wordpress 5.2.2:

version: '3'
services:
  wordpress:
    image: wordpress:5.2.2
    ports:
      - 8000:80
    restart: always
    volumes:
      - ./uploads:/var/www/html/wp-content/uploads
      - ./plugins:/var/www/html/wp-content/plugins
      - ./themes:/var/www/html/wp-content/themes
      - ./wp-config.php:/var/www/html/wp-config.php

这正在localhost:8000上运行容器。 当我尝试在网址上使用file_get_contents时,例如: file_get_contents('http://localhost:8000/wp-content/uploads/2018/07/discover.svg'); 我收到错误消息:

Warning: file_get_contents(http://localhost:8000/wp-content/uploads/2018/07/discover.svg): failed to open stream: Cannot assign requested address in /var/www/html/wp-content/themes/mytheme/test/php

我已经在wp-config中尝试了以下php ini设置:

@ini_set( 'allow_url_fopen', true);
@ini_set( 'allow_url_include', true);

任何帮助将不胜感激

0 个答案:

没有答案