Skip to content

Run PHP as the Docker Host's user #16

Description

@hopeseekr

The Problem

Sometimes you need to run CLI commands and they fail with dockerized PHP because there is a mismatch between the Docker Host's user (YOUR account, usually ID 1000) and the Docker Client's user (user, ID 9001 in your Docker containers).

E.g., "Permission denied" when running php artisan optimize:clear.

The Solution

The way I typically do this is:

docker run -u=$UID -v /etc/passwd:/etc/passwd:ro -it --rm --entrypoint=/usr/bin/php phpexperts/php:7.2 "$@"

I attempted to add this to this project, but I ran into the error:

image

I don't mind hacking through this in the future if you want the feature and have limited bandwidth.

Activity

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions