I am new to docker, but I'm starting to understand the basics. Basically with a docker-compose setup I am getting this error preventing the website from running:
wordpress_1 | sed: can't read wp-config*: No such file or directory
My setup is pretty simple:
// docker compose file
version: '3'
services:
db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
networks:
- wpsite
wordpress:
depends_on:
- db
image: mycustomwordpressimage
ports:
- '8000:80'
restart: always
volumes: ['./:/var/www/html']
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
WORDPRESS_DB_NAME: wordpress
networks:
- wpsite
networks:
wpsite:
volumes:
db_data:
I think it's something to do with my custom wp image which uses a custom wordpress image with my custom theme. Maybe i have to put env vars here?
// mycustomwordpressimage Dockerfile ( just a repo in the folder of the theme )
FROM wordpress:5-php7.4-fpm
COPY . /var/www/html/wp-content/themes/
if it's something with my syntax, or doing something stupid, please let me know I have no idea.
You don't need to create a custom image for this, if you just mount that directory everything will work.
Example:
services:
wordpress:
image: wordpress:5-php7.4-fpm
...
volumes:
- ./themes/:/var/www/html/wp-content/themes/
If you really want/need to create a custom image, you will have to modify/create a wrapper around docker-entrypoint.sh
( https://github.com/docker-library/wordpress/blob/master/php7.4/fpm/docker-entrypoint.sh ), this script is what is causing that error. On the first run it installs wordpress in /var/www/html
, which is a declared volume ( https://github.com/docker-library/wordpress/blob/master/php7.4/fpm/Dockerfile#L97 ).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.