Skip to content

Commit 27d9b18

Browse files
committed
Add a new section in the PHP documentation about running as an arbitrary user
This is adapated from what's discussed in docker-library/wordpress#249 (and docker-library/wordpress#256, among others).
1 parent 544a48a commit 27d9b18

File tree

4 files changed

+22
-0
lines changed

4 files changed

+22
-0
lines changed

drupal/content.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,7 @@ The following Docker Hub features can help with the task of keeping your depende
9696

9797
- [Automated Builds](https://docs.docker.com/docker-hub/builds/) let Docker Hub automatically build your Dockerfile each time you push changes to it.
9898
- [Repository Links](https://docs.docker.com/docker-hub/builds/#repository-links) can ensure that your image is also rebuilt any time `%%REPO%%` is updated.
99+
100+
## Running as an arbitrary user
101+
102+
See [the "Running as an arbitrary user" section of the `php` image documentation](https://hub.docker.com/_/php/).

owncloud/content.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,7 @@ $ docker exec -u www-data some-owncloud php occ status
4747
## %%STACK%%
4848

4949
Run `docker stack deploy -c stack.yml %%REPO%%` (or `docker-compose -f stack.yml up`), wait for it to initialize completely, and visit `http://swarm-ip:8080/`, `http://localhost:8080/`, or `http://host-ip:8080` (as appropriate).
50+
51+
## Running as an arbitrary user
52+
53+
See [the "Running as an arbitrary user" section of the `php` image documentation](https://hub.docker.com/_/php/).

php/content.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,16 @@ RUN curl -fsSL 'https://xcache.lighttpd.net/pub/Releases/3.2.0/xcache-3.2.0.tar.
178178
&& rm -r /tmp/xcache
179179
```
180180

181+
## Running as an arbitrary user
182+
183+
For running the FPM variants as an arbitrary user, the `--user` flag to `docker run` should be used (which can accept both a username/group in the container's `/etc/passwd` file like `--user daemon` or a specific UID/GID like `--user 1000:1000`).
184+
185+
For running the Apache variants as an arbitrary user, there are several choices:
186+
187+
- If your kernel [is version 4.11 or newer](https://github.com/moby/moby/issues/8460#issuecomment-312459310), you can add `--sysctl net.ipv4.ip_unprivileged_port_start=0` and then `--user` should work as it does for FPM.
188+
- If you adjust the Apache configuration to use an "unprivileged" port (greater than 1024 by default), then `--user` should work as it does for FPM regardless of kernel version.
189+
- Otherwise, setting `APACHE_RUN_USER` and/or `APACHE_RUN_GROUP` should have the desired effect (for example, `-e APACHE_RUN_USER=daemon` or `-e APACHE_RUN_USER=#1000` -- see [the Apache `User` directive documentation for details on the expected syntax](https://httpd.apache.org/docs/2.4/mod/mod_unixd.html#user)).
190+
181191
## "`E: Package 'php-XXX' has no installation candidate`"
182192

183193
As of [docker-library/php#542](https://github.com/docker-library/php/pull/542), this image blocks the installation of Debian's PHP packages. There is some additional discussion of this change in [docker-library/php#551 (comment)](https://github.com/docker-library/php/issues/551#issuecomment-354849074), but the gist is that installing Debian's PHP packages in this image leads to two conflicting installations of PHP in a single image, which is almost certainly not the intended outcome.

wordpress/content.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,7 @@ The following Docker Hub features can help with the task of keeping your depende
6262

6363
- [Automated Builds](https://docs.docker.com/docker-hub/builds/) let Docker Hub automatically build your Dockerfile each time you push changes to it.
6464
- [Repository Links](https://docs.docker.com/docker-hub/builds/#repository-links) can ensure that your image is also rebuilt any time `%%REPO%%` is updated.
65+
66+
## Running as an arbitrary user
67+
68+
See [the "Running as an arbitrary user" section of the `php` image documentation](https://hub.docker.com/_/php/).

0 commit comments

Comments
 (0)