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

Permission error on changing workdir with www-data user #903

Open
sajjadG opened this issue Jun 7, 2024 · 2 comments
Open

Permission error on changing workdir with www-data user #903

sajjadG opened this issue Jun 7, 2024 · 2 comments

Comments

@sajjadG
Copy link

sajjadG commented Jun 7, 2024

Following this solution #221 (comment) for changing wordpress to a subfolder, if I run the container with default user (root) everything works fine but if I set the user to anything else (whether the user exist in the image or not, or if the user has the permissions to the parent dir that the new dir is going to be created in), it can not create that dir and copy the wordpress files to it.

# docker run -it --rm wordpress ls -l /var/www/
total 4
drwxrwxrwt 3 www-data www-data 4096 Jun  7 07:37 html
# docker run -it --rm --user www-data -w /var/www/html/wordpress wordpress
WordPress not found in /var/www/html/wordpress - copying now...
tar: .: Cannot change mode to rwxr-xr-x: Operation not permitted
tar: ./wp-trackback.php: Cannot open: Permission denied
tar: ./wp-settings.php: Cannot open: Permission denied
tar: ./wp-load.php: Cannot open: Permission denied
tar: ./wp-config-sample.php: Cannot open: Permission denied
tar: ./wp-comments-post.php: Cannot open: Permission denied
tar: ./wp-admin: Cannot mkdir: Permission denied
tar: ./wp-admin: Cannot mkdir: Permission denied
tar: ./wp-admin/images: Cannot mkdir: No such file or directory
tar: ./wp-admin: Cannot mkdir: Permission denied
tar: ./wp-admin/images/post-formats32-vs.png: Cannot open: No such file or directory
...
@sajjadG
Copy link
Author

sajjadG commented Jun 7, 2024

If the dir exist with the right owner and permissions then it works

# mkdir -p wp/blog/
# chown -R www-data:www-data wp/
# docker run -it --rm --user www-data -v ./wp:/var/www/html -w /var/www/html/blog wordpress
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.0.5. Set the 'ServerName' directive globally to suppress this message
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.0.5. Set the 'ServerName' directive globally to suppress this message
[Fri Jun 07 08:00:34.917602 2024] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.59 (Debian) PHP/8.2.20 configured -- resuming normal operations
[Fri Jun 07 08:00:34.918542 2024] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'

@tianon
Copy link
Member

tianon commented Jun 7, 2024

If the dir exist with the right owner and permissions then it works

This is expected -- if we're running as non-root (--user www-data), we can't automatically fix this in any way. 😅

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

2 participants