Skip to content

Docker CLI Image - Permission issues.  #908

@Jack-Dane

Description

@Jack-Dane

Possibly related to #906.

The cli:latest docker image doesn't have the xfs user (assigned to UID 33). When trying to run CLI commands to install plugins, I get permission errors:

test_wpcli-1      | Success: WordPress installed successfully.
test_wpcli-1      | Warning: Unable to create directory wp-content/uploads/2024/07. Is its parent directory writable by the server?
test_wpcli-1      | Installing Contact Form 7 (5.9.6)
test_wpcli-1      | Downloading installation package from https://downloads.wordpress.org/plugin/contact-form-7.5.9.6.zip...
test_wpcli-1      | Unpacking the package...
test_wpcli-1      | Warning: Could not create directory. "/var/www/html/wp-content/upgrade"
test_wpcli-1      | Warning: The 'contact-form-7' plugin could not be found.
test_wpcli-1      | Error: No plugins installed.
test_wpcli-1      | Warning: Failed to activate plugin. Contact Form 7 to Odoo connector requires 1 plugin to be installed and activated: contact-form-7. .
test_wpcli-1      | Error: No plugins activated.

This user used to have a shared UID with the www-data user (in the base Wordpress container), but the xfs has been removed.

Wordpress CLI Container

jack@jackd:~/Documents/odoo-wp-plugin$ docker exec -it end_to_end_tests-test_wpcli-1 bash
5e2a63b1772e:/var/www/html$ ls
index.php             wp-activate.php       wp-comments-post.php  wp-config.php         wp-includes           wp-login.php          wp-signup.php
license.txt           wp-admin              wp-config-docker.php  wp-content            wp-links-opml.php     wp-mail.php           wp-trackback.php
readme.html           wp-blog-header.php    wp-config-sample.php  wp-cron.php           wp-load.php           wp-settings.php       xmlrpc.php
5e2a63b1772e:/var/www/html$ ls -l
total 248
-rw-r--r--    1 33       33             405 Feb  6  2020 index.php
-rw-r--r--    1 33       33           19915 Jan  1  2024 license.txt
-rw-r--r--    1 33       33            7401 Dec  8  2023 readme.html
-rw-r--r--    1 33       33            7387 Feb 13 14:19 wp-activate.php
drwxr-xr-x    9 33       33            4096 Jun 24 17:16 wp-admin
-rw-r--r--    1 33       33             351 Feb  6  2020 wp-blog-header.php
-rw-r--r--    1 33       33            2323 Jun 14  2023 wp-comments-post.php
-rw-r--r--    1 33       33            5512 Jul  2 06:08 wp-config-docker.php
-rw-r--r--    1 33       33            3012 Nov 22  2023 wp-config-sample.php
-rw-r--r--    1 33       33            5616 Jul  2 21:11 wp-config.php
drwxr-xr-x    5 33       33            4096 Jun 24 17:16 wp-content
-rw-r--r--    1 33       33            5638 May 30  2023 wp-cron.php
drwxr-xr-x   30 33       33           16384 Jun 24 17:16 wp-includes
-rw-r--r--    1 33       33            2502 Nov 26  2022 wp-links-opml.php
-rw-r--r--    1 33       33            3927 Jul 16  2023 wp-load.php
-rw-r--r--    1 33       33           50917 Jan 16 17:31 wp-login.php
-rw-r--r--    1 33       33            8525 Sep 16  2023 wp-mail.php
-rw-r--r--    1 33       33           28427 Mar  2 10:47 wp-settings.php
-rw-r--r--    1 33       33           34385 Jun 19  2023 wp-signup.php
-rw-r--r--    1 33       33            4885 Jun 22  2023 wp-trackback.php
-rw-r--r--    1 33       33            3246 Mar  2 13:49 xmlrpc.php
5e2a63b1772e:/var/www/html$ cat /etc/passwd
root:x:0:0:root:/root:/bin/sh
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/mail:/sbin/nologin
news:x:9:13:news:/usr/lib/news:/sbin/nologin
uucp:x:10:14:uucp:/var/spool/uucppublic:/sbin/nologin
cron:x:16:16:cron:/var/spool/cron:/sbin/nologin
ftp:x:21:21::/var/lib/ftp:/sbin/nologin
sshd:x:22:22:sshd:/dev/null:/sbin/nologin
games:x:35:35:games:/usr/games:/sbin/nologin
ntp:x:123:123:NTP:/var/empty:/sbin/nologin
guest:x:405:100:guest:/dev/null:/sbin/nologin
nobody:x:65534:65534:nobody:/:/sbin/nologin
www-data:x:82:82:Linux User,,,:/home/www-data:/sbin/nologin
5e2a63b1772e:/var/www/html$ 

This means I cannot install plugins, as there isn't a user that has access to these files.

WordPress Container

jack@jackd:~/Documents/odoo-wp-plugin$ docker container exec -it 34adc3f6ca76 bash
root@34adc3f6ca76:/var/www/html# ls -l
total 248
-rw-r--r--  1 www-data www-data   405 Feb  6  2020 index.php
-rw-r--r--  1 www-data www-data 19915 Jan  1  2024 license.txt
-rw-r--r--  1 www-data www-data  7401 Dec  8  2023 readme.html
-rw-r--r--  1 www-data www-data  7387 Feb 13 14:19 wp-activate.php
drwxr-xr-x  9 www-data www-data  4096 Jun 24 17:16 wp-admin
-rw-r--r--  1 www-data www-data   351 Feb  6  2020 wp-blog-header.php
-rw-r--r--  1 www-data www-data  2323 Jun 14  2023 wp-comments-post.php
-rw-r--r--  1 www-data www-data  5512 Jul  2 06:08 wp-config-docker.php
-rw-r--r--  1 www-data www-data  3012 Nov 22  2023 wp-config-sample.php
-rw-r--r--  1 www-data www-data  5616 Jul  2 21:11 wp-config.php
drwxr-xr-x  7 www-data www-data  4096 Jul  2 21:31 wp-content
-rw-r--r--  1 www-data www-data  5638 May 30  2023 wp-cron.php
drwxr-xr-x 30 www-data www-data 16384 Jun 24 17:16 wp-includes
-rw-r--r--  1 www-data www-data  2502 Nov 26  2022 wp-links-opml.php
-rw-r--r--  1 www-data www-data  3927 Jul 16  2023 wp-load.php
-rw-r--r--  1 www-data www-data 50917 Jan 16 17:31 wp-login.php
-rw-r--r--  1 www-data www-data  8525 Sep 16  2023 wp-mail.php
-rw-r--r--  1 www-data www-data 28427 Mar  2 10:47 wp-settings.php
-rw-r--r--  1 www-data www-data 34385 Jun 19  2023 wp-signup.php
-rw-r--r--  1 www-data www-data  4885 Jun 22  2023 wp-trackback.php
-rw-r--r--  1 www-data www-data  3246 Mar  2 13:49 xmlrpc.php
root@34adc3f6ca76:/var/www/html# cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
sys:x:3:3:sys:/dev:/usr/sbin/nologin
sync:x:4:65534:sync:/bin:/bin/sync
games:x:5:60:games:/usr/games:/usr/sbin/nologin
man:x:6:12:man:/var/cache/man:/usr/sbin/nologin
lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin
mail:x:8:8:mail:/var/mail:/usr/sbin/nologin
news:x:9:9:news:/var/spool/news:/usr/sbin/nologin
uucp:x:10:10:uucp:/var/spool/uucp:/usr/sbin/nologin
proxy:x:13:13:proxy:/bin:/usr/sbin/nologin
www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin
backup:x:34:34:backup:/var/backups:/usr/sbin/nologin
list:x:38:38:Mailing List Manager:/var/list:/usr/sbin/nologin
irc:x:39:39:ircd:/run/ircd:/usr/sbin/nologin
_apt:x:42:65534::/nonexistent:/usr/sbin/nologin
nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin
root@34adc3f6ca76:/var/www/html# 

I can no longer use the xfs in user as the CLI user.

I am unsure if the xfs was supposed to share the UID of the www-data to ease permission issues, or if this was just a happy coincidence and another solution needs to be used.

Workaround
Use an older CLI image, eg: wordpress:cli-2.9.0-php8.3 resolves this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions