Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin install fails #417

Closed
narthur opened this issue Jul 23, 2019 · 9 comments
Closed

Plugin install fails #417

narthur opened this issue Jul 23, 2019 · 9 comments

Comments

@narthur
Copy link

narthur commented Jul 23, 2019

I'm trying to run the following command using the CLI:

docker run -it -u 33 --rm \
    --volumes-from [image name] \
    --network container:[image name] \
    wordpress:cli plugin install wordpress-importer --activate

I get the following output:

PHP Warning: Failed loading Zend extension 'xdebug.so' (tried: /usr/local/lib/php/extensions/no-debug-non-zts-20180731/xdebug.so (Error loading shared library /usr/local/lib/php/extensions/no-debug-non-zts-20180731/xdebug.so: No such file or directory), /usr/local/lib/php/extensions/no-debug-non-zts-20180731/xdebug.so.so (Error loading shared library /usr/local/lib/php/extensions/no-debug-non-zts-20180731/xdebug.so.so: No such file or directory)) in Unknown on line 0
Installing WordPress Importer (0.6.4)
Warning: Failed to create directory '/etc/X11/fs/.wp-cli/cache/': mkdir(): Permission denied.
Downloading installation package from https://downloads.wordpress.org/plugin/wordpress-importer.0.6.4.zip...
The authenticity of wordpress-importer.0.6.4.zip could not be verified as no signature was found.
Unpacking the package...
Warning: Could not create directory.
Warning: The 'wordpress-importer' plugin could not be found.
Error: No plugins installed.

I've tried adding the following to my Dockerfile, which successfully sets the directories to be owned by www-data, but the errors don't go away:

RUN mkdir -p /etc/X11/fs/.wp-cli/cache/
RUN chown -R www-data:www-data /etc/X11/fs/.wp-cli/cache/
RUN find /etc/X11/fs/.wp-cli/ -type d -exec chmod 0755 {} \;
RUN find /etc/X11/fs/.wp-cli/ -type f -exec chmod 644 {} \;

RUN mkdir -p /var/www/html/wp-content/plugins
RUN mkdir -p /var/www/html/wp-content/uploads
RUN chown -R www-data:www-data /var/www
RUN find /var/www/ -type d -exec chmod 0755 {} \;
RUN find /var/www/ -type f -exec chmod 644 {} \;

What do I need to do to fix these errors?

@wglambert
Copy link

wordpress:cli uses Alpine which uses uid 82 for the user www-data as opposed to Debian's uid 33
https://github.com/docker-library/docs/tree/master/wordpress#running-as-an-arbitrary-user
And for the cli to communicate with WordPress they need to be using the same uid, and while Apache can run as www-data and have the host be root; wp-cli can't.

So those root owned directories are kind of stuck like that for cli since it can't be root

You can however install it from the WordPress admin panel since the user in the WordPress container has sufficient permissions.
wurdpres

@narthur
Copy link
Author

narthur commented Jul 23, 2019

Hmm, that's unfortunate since the CLI image seems to be the recommended way to use the CLI with the WordPress image. Any chance a CLI image based on Debian could be published?

Thanks for the explanation. :)

@wglambert
Copy link

So your issue is actually far simpler, it didn't make sense that an extension wanted to write to /etc/, and also that WordPress which also runs as non-root could install the extension.

When you do a -u 33 it changes the $HOME directory to /etc/X11/fs/ so if you modify that to instead be the writable /tmp/ directory then it should work

@tianon
Copy link
Member

tianon commented Jul 23, 2019

Good catch -- doc update in docker-library/docs#1539 👍 😅

@wglambert
Copy link

Installing wordpress-importer against a running WordPress container

$ docker run -it -u 33 -e HOME=/tmp --rm \
> --volumes-from wordpress_wordpress_1 \                                                                                                          
> --network container:wordpress_wordpress_1 \                                                                                                     
> wordpress:cli plugin install wordpress-importer --activate

Installing WordPress Importer (0.6.4)
Downloading installation package from https://downloads.wordpress.org/plugin/wordpress-importer.0.6.4.zip...                                      
Unpacking the package...                                                                                                                          
Installing the plugin...                                                                                                                          
Plugin installed successfully.                                                                                                                    
Activating 'wordpress-importer'...                                                                                                                
Plugin 'wordpress-importer' activated.                                                                                                            
Success: Installed 1 of 1 plugins.

@narthur
Copy link
Author

narthur commented Jul 23, 2019

@wglambert Hmm, that looks very promising...

Modified command:

docker run -it -u 33 -e HOME=/tmp --rm \
    --volumes-from [image name] \
    --network container:[image name] \
    wordpress:cli plugin install wordpress-importer --activate

Output:

[23-Jul-2019 20:16:09 UTC] PHP Warning: Failed loading Zend extension 'xdebug.so' (tried: /usr/local/lib/php/extensions/no-debug-non-zts-20180731/xdebug.so (Error loading shared library /usr/local/lib/php/extensions/no-debug-non-zts-20180731/xdebug.so: No such file or directory), /usr/local/lib/php/extensions/no-debug-non-zts-20180731/xdebug.so.so (Error loading shared library /usr/local/lib/php/extensions/no-debug-non-zts-20180731/xdebug.so.so: No such file or directory)) in Unknown on line 0
Installing WordPress Importer (0.6.4)
Downloading installation package from https://downloads.wordpress.org/plugin/wordpress-importer.0.6.4.zip...
The authenticity of wordpress-importer.0.6.4.zip could not be verified as no signature was found.
Unpacking the package...
Warning: Could not create directory.
Warning: The 'wordpress-importer' plugin could not be found.
Error: No plugins installed.

I'm really stumped... I've tried several combinations of the following in my dockerfile to try to fix the permissions issue I imagine I must be running into, but nothing's fixed it:

RUN chown -R www-data:www-data /tmp
RUN find /tmp -type d -exec chmod 0755 {} \;
RUN find /tmp -type f -exec chmod 644 {} \;

RUN mkdir -p /var/www/html/wp-content/plugins
RUN mkdir -p /var/www/html/wp-content/uploads
RUN chown -R www-data:www-data /var/www
RUN find /var/www/ -type d -exec chmod 0755 {} \;
RUN find /var/www/ -type f -exec chmod 644 {} \;

@narthur narthur reopened this Jul 23, 2019
@wglambert
Copy link

Your --volumes-from might be getting misc configuration data from WordPress (such as the php.ini etc...).

You could try mounting just the singular volume that WordPress has mounted such as its /var/www/html/ volume. Either including the name for a Docker-controlled volume or the path on the host for a bind-mounted one.

@narthur
Copy link
Author

narthur commented Jul 24, 2019

Figured it out... Turns out changing the permissions of the plugins folder in the Dockerfile wasn't working... Seemed like they were getting reverted. I've added the permissions change to a setup script I run after the container is running.

@omars44
Copy link

omars44 commented Sep 20, 2022

@wglambert Hmm, that looks very promising...

Modified command:

docker run -it -u 33 -e HOME=/tmp --rm \
    --volumes-from [image name] \
    --network container:[image name] \
    wordpress:cli plugin install wordpress-importer --activate

Output:

[23-Jul-2019 20:16:09 UTC] PHP Warning: Failed loading Zend extension 'xdebug.so' (tried: /usr/local/lib/php/extensions/no-debug-non-zts-20180731/xdebug.so (Error loading shared library /usr/local/lib/php/extensions/no-debug-non-zts-20180731/xdebug.so: No such file or directory), /usr/local/lib/php/extensions/no-debug-non-zts-20180731/xdebug.so.so (Error loading shared library /usr/local/lib/php/extensions/no-debug-non-zts-20180731/xdebug.so.so: No such file or directory)) in Unknown on line 0
Installing WordPress Importer (0.6.4)
Downloading installation package from https://downloads.wordpress.org/plugin/wordpress-importer.0.6.4.zip...
The authenticity of wordpress-importer.0.6.4.zip could not be verified as no signature was found.
Unpacking the package...
Warning: Could not create directory.
Warning: The 'wordpress-importer' plugin could not be found.
Error: No plugins installed.

I'm really stumped... I've tried several combinations of the following in my dockerfile to try to fix the permissions issue I imagine I must be running into, but nothing's fixed it:

RUN chown -R www-data:www-data /tmp
RUN find /tmp -type d -exec chmod 0755 {} \;
RUN find /tmp -type f -exec chmod 644 {} \;

RUN mkdir -p /var/www/html/wp-content/plugins
RUN mkdir -p /var/www/html/wp-content/uploads
RUN chown -R www-data:www-data /var/www
RUN find /var/www/ -type d -exec chmod 0755 {} \;
RUN find /var/www/ -type f -exec chmod 644 {} \;

The thing is this will not solve the problem, because this is pre mounting docker volumes, so it wont have any effect, conversely if you have an entrypoint, doing exactly the same, this will fix the problem, knowing that entrypoints are executed after the volumes were mounted.

Best

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants