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

www-data user mismatch cli / wordpress images #256

Closed
uda opened this issue Dec 4, 2017 · 10 comments
Closed

www-data user mismatch cli / wordpress images #256

uda opened this issue Dec 4, 2017 · 10 comments

Comments

@uda
Copy link

uda commented Dec 4, 2017

I am deploying some Wordpress instances, each is a network of sites.

The wp-cli image is based on alpine, only. the Apache image is based on Debian, only. the FPM uses both Debian and alpine, but that requires another HTTP container or configuring FCGI in the LB instead of a simple proxy.

When using the wp-cli on a volume from an Apache image, you can't save the changes into the wp-config.php file, because the www-data user has different uids on alpine and debian.

So I suggest to implement the following (I thing the first is the simplest):

  • wp-cli should be available on all Wordpress images, so using docker-compose exec wordpress multisite-install ... will be more efficient than having a separate service for the cli.
  • wp-cli should have a debian based flavor where www-data has the same uid like the wordpress image.

Here is my current (initial) setup: https://github.com/uda/docker-wp-ms

@uda uda changed the title user mismatch cli / wordpress images www-data user mismatch cli / wordpress images Dec 4, 2017
@jaswrks
Copy link

jaswrks commented Feb 6, 2018

Basically the same problem explained in a slightly different way, but in great detail, in #279. That issue is now closed as a duplicate, but perhaps still worth reviewing.

@tianon
Copy link
Member

tianon commented Feb 6, 2018

There shouldn't be anything preventing running the wordpress:cli variants as whatever UID you want (or even the non-cli variants, for that matter; see #249).

I'd love to get the IDs to match up, but that's not a great solution since in both instances, the www-data user comes from the base image itself (not something we create), and IMO it's not a huge problem since you can choose any runtime ID you want for all associated images.

@mfdeveloper
Copy link

mfdeveloper commented Mar 24, 2018

Hello there!! My current solution was, create a custom Dockerfile, copy the whole content from cli/DockerFile and remove the line USER www-data. By default, whether not pass a user, docker login like root. So, access the container and use wp-cli commands with --allow-root. For me it's not a problem, because I'm using WP in a docker container by development and CI.

@tianon This can be a official solution? Or installing wp-cli directly to wordpress image like described into the issue #283 ?

@tianon
Copy link
Member

tianon commented Apr 19, 2018

I would love to see a clean solution to this, but as I stated above, I really don't see any way we can cleanly resolve this (especially in a way that doesn't break existing users). Both images should allow either using --user or APACHE_RUN_USER to set an explicit UID for running as, and thus this is pretty easy for users to control directly. 👍

@tianon tianon closed this as completed Apr 19, 2018
tianon added a commit to infosiftr/docker-library-docs that referenced this issue May 8, 2018
candrews added a commit to candrews/versionpress that referenced this issue Mar 6, 2019
…hp7.2-apache

versionpress/wordpress:php7.2-apache is based on wordpress:php7.2-apache which is based on debian.

On Debian, www-data:www-data is 33:33
On Alpine (which is what cli is based on), www-data:www-data is 82:82
Therefore, when Alpine and Debian interact, one has to change to match the other.

See docker-library/wordpress#256 for details
candrews added a commit to candrews/versionpress that referenced this issue Mar 6, 2019
…hp7.2-apache

versionpress/wordpress:php7.2-apache is based on wordpress:php7.2-apache which is based on debian.

On Debian, www-data:www-data is 33:33
On Alpine (which is what cli is based on), www-data:www-data is 82:82
Therefore, when Alpine and Debian interact, one has to change to match the other.

See docker-library/wordpress#256 for details
candrews added a commit to candrews/versionpress that referenced this issue Mar 6, 2019
…hp7.2-apache

versionpress/wordpress:php7.2-apache is based on wordpress:php7.2-apache which is based on debian.

On Debian, www-data:www-data is 33:33
On Alpine (which is what cli is based on), www-data:www-data is 82:82
Therefore, when Alpine and Debian interact, one has to change to match the other.

See docker-library/wordpress#256 for details
candrews added a commit to candrews/versionpress that referenced this issue Mar 7, 2019
…hp7.2-apache

versionpress/wordpress:php7.2-apache is based on wordpress:php7.2-apache which is based on debian.

On Debian, www-data:www-data is 33:33
On Alpine (which is what cli is based on), www-data:www-data is 82:82
Therefore, when Alpine and Debian interact, one has to change to match the other.

See docker-library/wordpress#256 for details
noisysocks added a commit to WordPress/gutenberg that referenced this issue Feb 24, 2020
The www-data user in wordpress:cli has a different UID (82) to the
www-data user in wordpress (33). Ensure we use the wordpress www-data
user for CLI commands.

See docker-library/wordpress#256 for more
discussion.
noisysocks added a commit to WordPress/gutenberg that referenced this issue Feb 24, 2020
The www-data user in wordpress:cli has a different UID (82) to the
www-data user in wordpress (33). Ensure we use the wordpress www-data
user for CLI commands.

See docker-library/wordpress#256 for more
discussion.
jorgefilipecosta pushed a commit to WordPress/gutenberg that referenced this issue Mar 2, 2020
The www-data user in wordpress:cli has a different UID (82) to the
www-data user in wordpress (33). Ensure we use the wordpress www-data
user for CLI commands.

See docker-library/wordpress#256 for more
discussion.
jorgefilipecosta pushed a commit to WordPress/gutenberg that referenced this issue Mar 2, 2020
The www-data user in wordpress:cli has a different UID (82) to the
www-data user in wordpress (33). Ensure we use the wordpress www-data
user for CLI commands.

See docker-library/wordpress#256 for more
discussion.
@ArTeM821121
Copy link

today is 2024, i am still trying to solve this problem. Did someone find the solution?

@tianon
Copy link
Member

tianon commented Nov 21, 2024

As noted above, the best case solution is --user on your containers so that they explicitly match both each other and your underlying storage permissions.

@ArTeM821121
Copy link

Thanks, I'll try. My problem occurs in docker compose when trying to deploy wordpress and wp_cli containers. When explicitly designating the user as user: www-data, a problem with rights occurs. This allows you to install plugins, but ruins the entire system of loading other files. When i am trying to install a template for a site, an error occurs, saying that wordpress cannot access directories

@tianon
Copy link
Member

tianon commented Nov 21, 2024

You want to specify an explicit UID, not a name (user: '1000:1000' or user: '33:33', for example).

@ArTeM821121
Copy link

Thanks, I found another solution. My task was to automatically install the required set of plugins when deploying WordPress in Docker Compose. A solution that does not cause problems with rights is to install using a curl request, which must be written in the WordPress command. Then we do not need to install wp_cli, everything is done automatically and quickly.

@ArTeM821121
Copy link

ArTeM821121 commented Nov 22, 2024

curl requst of the plugin what you need

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

5 participants