I need to embed svg from php. And for this I used
<?= file_get_contents( get_template_directory_uri() . "/images/scroll_to_explore.svg" ) ?>
When I served project locally, all were fine. But now project migrated to Docker. And I got next errors everywhere I have same code:
Warning: file_get_contents(http://0.0.0.0:8000/wp-content/themes/my_theme/images/scroll.svg):
Failed to open stream: Connection refused in /var/www/html/wp-content/themes/my_theme/parts/front/cover.php
This is my docker-compose.yml
:
version: '3.3'
services:
db:
image: mysql:latest
volumes:
- ./database.sql:/docker-entrypoint-initdb.d/init.sql # prepopulate database
- db_data:/var/lib/mysql # persist database data inside docker storage
restart: always
env_file:
- .env
environment:
DOCKER_COMPOSE_YML_LOCATION: ${PWD}
container_name: wp_db
phpmyadmin:
image: phpmyadmin/phpmyadmin
restart: always
ports:
- "8080:80"
volumes:
- /sessions
environment:
PMA_HOST: db
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
DOCKER_COMPOSE_YML_LOCATION: ${PWD}
UPLOAD_LIMIT: 300M
container_name: wp_phpmyadmin
depends_on:
- db
wordpress:
depends_on:
- db
image: wordpress:latest
ports:
- "8000:80"
restart: always
environment:
# debug mode
WORDPRESS_DEBUG: 1
# docker wp config settings
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: ${MYSQL_USER}
WORDPRESS_DB_PASSWORD: ${MYSQL_PASSWORD}
WORDPRESS_DB_NAME: ${MYSQL_DATABASE}
DOCKER_COMPOSE_YML_LOCATION: ${PWD}
volumes:
# Theme, plugins and uploads
- ./wp-content:/var/www/html/wp-content
# Configurations
- .htaccess:/var/www/html/.htaccess
# PHP Configuration
- ./php-extra.ini:/usr/local/etc/php/conf.d/php-extra.ini
container_name: wp_wordpress
volumes:
db_data: {}
This is my php-extra.ini
:
allow_url_fopen: 1
I tried to add custom php configuration to php-extra.ini
but it didn't help
Check your configuration. You really shouldn't try to connect via 0.0.0.0
... it's a special address for configuring the server to listen on any interface.
If this file you need is on disk, there's no need to load via HTTP anyway. If you do need to load it over HTTP, consider 127.0.0.1
or localhost
instead.