Search code examples
wordpressdockerpluginsdockerfileactivation

How to automatically activate the plugin while wordpress first installation using docker


Intalling wordpress on Docker. I have pushed the wordpress custom image with my plugins pre-installed on docker hub. I am ruuning wordpress using docker-compose. how to enable the installed plugins using first installation.

Dockerfile

FROM wordpress:php7.1-apache
#FROM bitnami/wordpress:latest

# WORKDIR /var/www/html

COPY wordpress-seo /var/www/html/wp-content/plugins/wordpress-seo/
COPY wp-super-cache /var/www/html/wp-content/plugins/wp-super-cache/


COPY activate-wordpress-plugins.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/activate-wordpress-plugins.sh

# RUN wp plugin activate wp-super-cache --allow-root --path=/var/www/html
# RUN wp plugin activate akismet --allow-root --path=/var/www/html
# RUN wp plugin activate wordpress-seo --allow-root --path=/var/www/html

# If downloaded via url
#wget -P /temp/plugins/ https://downloads.wordpress.org/plugin/jetpack.5.9.zip
# Extract and delete zip files
#RUN unzip '/temp/plugins/*.zip' -d /temp/plugins && rm /temp/plugins/*.zip || true;

#COPY functions.php /var/www/html/wp-content/themes/twentynineteen/

activate-wordpress-plugins.sh

echo docker-compose up -d
docker-compose up -d

echo docker exec -it $(docker-compose ps -q wordpress)  /usr/local/bin/activate-wordpress-plugins.sh
docker exec -it $(docker-compose ps -q wordpress)   /usr/local/bin/activate-wordpress-plugins.sh

Plugins are installed but not activated.


Solution

  • Once you integrate the wordpress cli into the image or run seprate wpcli image using compose file. You can simply use wp-cli commands to activate the plugins and install wordpress.