我已经使用wordpress
用wordpress cli
图像构建了Docker Compose
。效果很好。现在,我要在其中安装plugins
。
我的plugin zip
文件位于放置docker_compose.yml
文件的目录中。我想在docker compose
文件中添加行以安装插件并将其加载到Docker容器中。
这是我写的yml文件:
version: "3.3"
services:
db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_RANDOM_ROOT_PASSWORD: 1
MYSQL_DATABASE: wordpressdb
MYSQL_USER: paulsteven
MYSQL_PASSWORD: passw
wordpress:
depends_on:
- db
image: wordpress:latest
ports:
- 8000:80
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_NAME: wordpressdb
WORDPRESS_DB_USER: paulsteven
WORDPRESS_DB_PASSWORD: passw
WORDPRESS_TABLE_PREFIX: "wp_"
WORDPRESS_DEBUG: 1
volumes:
- wp_data:/var/www/html
- ./wp_plugins_files: /var/www/html ==> here it is,but it does not loaded and installed in container
wordpress-cli:
depends_on:
- db
- wordpress
image: wordpress:cli
user: xfs
command: >
/bin/sh -c '
sleep 10;
wp core install --path="/var/www/html" --url="http://192.168.1.34:8000" --title="Local Wordpress By Docker" --admin_user=paulsteven --admin_password=pass --admin_email=paulsteven@mail.com;
wp plugin install gutenberg.1.9.1.zip –activate ==> Install plugin in Container
'
volumes:
- wp_data:/var/www/html
volumes:
db_data:
wp_data:
但是我的文件没有加载到容器中。我不知道该怎么做。我想要安装了我的插件文件的容器。为我提供一些解决方案。
答案 0 :(得分:0)
以下是有关您的代码的解决方案:
version: "3.3"
services:
db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_RANDOM_ROOT_PASSWORD: 1
MYSQL_DATABASE: wordpressdb
MYSQL_USER: paulsteven
MYSQL_PASSWORD: passw
wordpress:
depends_on:
- db
image: wordpress:latest
ports:
- 8000:80
restart: unless-stopped
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_NAME: wordpressdb
WORDPRESS_DB_USER: paulsteven
WORDPRESS_DB_PASSWORD: passw
WORDPRESS_TABLE_PREFIX: "wp_"
WORDPRESS_DEBUG: 1
volumes:
- wp_data:/var/www/html
- ./wp_plugins:/var/www/html/wp_plugins
wordpress-cli:
depends_on:
- db
- wordpress
image: wordpress:cli
user: xfs
command: >
/bin/sh -c '
sleep 10;
wp core install --path="/var/www/html" --url="http://192.168.1.34:8000" --title="Local Wordpress By Docker" --admin_user=paulsteven --admin_password=passw --admin_email=paulstevens@mail.com;
wp plugin install /var/www/html/wp_plugins/plugin_name.zip;
wp plugin activate plugin_name'
volumes:
- wp_data:/var/www/html
- ./wp_plugins:/var/www/html/wp_plugins
volumes:
db_data: