我们创建wordpress的时候要创建.yml文件内容如下
version: '3.3'
services:
db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: example_root_password
MYSQL_DATABASE: example_database
MYSQL_USER: example_user
MYSQL_PASSWORD: example_password
wordpress:
depends_on:
- db
image: wordpress:latest
ports:
- "8000:80"
restart: always
volumes:
- wp_data:/var/www/html
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_NAME: example_database
WORDPRESS_DB_USER: example_user
WORDPRESS_DB_PASSWORD: example_password
volumes:
db_data:
wp_data:
把内容修改一下新增一个 volume 映射,将本地的 php.ini 文件映射到容器内的 /usr/local/etc/php/php.ini 文件,从而实现自定义 php.ini 配置文件。
version: '3.3'
services:
db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: example_root_password
MYSQL_DATABASE: example_database
MYSQL_USER: example_user
MYSQL_PASSWORD: example_password
wordpress:
depends_on:
- db
image: wordpress:latest
ports:
- "8000:80"
restart: always
volumes:
- ./php.ini:/usr/local/etc/php/php.ini
- wp_data:/var/www/html
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_NAME: example_database
WORDPRESS_DB_USER: example_user
WORDPRESS_DB_PASSWORD: example_password
volumes:
db_data:
wp_data:
然后我们创建php.ini文件内容修改如下
post_max_size = 32M
upload_max_filesize = 32M
memory_limit = 256M
这样就已经成功使用 Docker Compose 实现了自定义 php.ini 配置文件。
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END
暂无评论内容