When developing Laravel locally with Docker instead of Laradock, Permission Denied failed to write / storage / logs
.
I will leave a workaround in this case.
Probably the cause of Permission Denied is that the UID and GID are different between the host and the client.
When the configuration is Nginx> php-fpm by docker-compose, make it possible to specify any UID and GID for the Nginx user www-data
in the Dockerfile on the php-fpm side as shown below. ..
Dockerfile
ARG PUID=1000
ARG PGID=1000
RUN echo "-> $PUID"
RUN echo "-> $PGID"
RUN groupmod -o -g $PGID www-data && \
usermod -o -u $PUID -g www-data www-data
Insert the UID and GID of your Mac when docker-compose build
.
$ docker-compose build --build-arg PUID=$(id -u) --build-arg PGID=$(id -g) app
Now the UID and GID of the host and client are the same.
$ (Id -u)
could not be resolved correctly when the above command was set in the Makefile.
It works well if you write as follows
Makefile
build_app:
$(eval UID := $(shell id -u))
$(eval GID := $(shell id -g))
@docker-compose build --build-arg PUID=$(UID) --build-arg PGID=$(GID) app
Recommended Posts