1

I have a containerized Laravel app. All my containers are running. When I run the command docker-compose exec app php artisan tinker, I get the error

   ErrorException 

  Writing to directory /home/darula/.config/psysh is not allowed.

Other artisan commands like docker compose exec app php artisan migrate work just fine.

I tried to change the ownership of the directory to the current owner. Also tried to change the permissions of the .config directory to 755. When I run php artisan tinker without the docker-compose, the command runs just file. Also when I run the php artisan tinker in a non containerized app, it works just fine.

Anything I need to do in order to run tinker on a containerized app?

daRula
  • 143
  • 2
  • 12

1 Answers1

1

I encontered the same error, after creating a customized docker for my project.

Don't know if it is your case, but in the comment, it says that docker needs a valid user to run.

To check just attach the docker shell running the laravel app and see if it the 'user' appears as having no name.

If it doesn't have a "name" you just need to modify your Dockerfile script addding a user.

# Variables to configure user and permissions
ARG WWWUSER=www
ARG WWWGROUP=www
ARG UID=1000
ARG GID=1000

# Add user for laravel application
RUN groupadd -g ${GID} ${WWWGROUP}
RUN useradd -u ${UID} -ms /bin/bash -g ${WWWGROUP} ${WWWUSER}

USER ${WWWUSER}

You can pass the argumments as a variable in your docker-compose.yml usually UID and GID are 1000, to confirm you can run:

id -u # To check your user ID

and

id -g # To check your group

The WWWUSER and WWWGROUP is just a user to run your system as internally, like sail.

Re-build your container and start it up. In my case it fixed.