Skip to content

Docker: Launch the php image with a non root user #1847

Closed as not planned
Closed as not planned

Description

@J3m5

API Platform version(s) affected: 2.6.3

Description
I tried to launch the php docker image with a non root user but I'm facing problems.
I added the instruction USER www-data at the end of the api-platform-php stage of the dockerfile, (this user is created in the original php-fpm-alpine image),
but then I get permission errors with the commands executed in the docker-entrypoint.sh file.

I tried to change the permissions of the php and composer bin, api/var files etc but it didn't works.

How to reproduce
Run docker-compose with the www-data user set in the dockerfile or in the php service of the docker-compose file.

Additional Context
Configuring and running the containers with a non root user is a requirement from our web host.
The images are meant to be running in a kubernetes environment hosted and managed by a certified health data host.

Activity

  1. J3m5 commented on Mar 22, 2021

    @J3m5
    ContributorAuthor

    I've managed to get it working, the whole stack is running with a non root user now.
    I'll post our setup here soon.

  2. added a commit that references this issue on May 4, 2022
    b35e669
  3. soyuka commented on May 19, 2026

    @soyuka
    Member

    Closing per #2987 — this repository is becoming a CLI installer. The previous Docker/template distribution is being superseded by the installer + upstream symfony-docker. If the issue still reproduces with the new setup, please open it on dunglas/symfony-docker (for Docker/Caddy/FrankenPHP issues) or api-platform/core (for framework issues).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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