Hi everyone!
Welcome to the first blog post of my life:) The main reason I decided to create a blog is to improve my writing skills in English. I decided to start just describing my everyday programming problems, so if anyone will find something interesting in the future, that would be great!
Introduction
I'm developing an application in Laravel and Vue using dockered php-fpm and nginx services.
I have used out of the box sail solution previously, but I wanted to have simultaneus requests handling.
I decided to use great boilerplate Dockerfile from this repo:
https://github.com/Cyber-Duck/php-fpm-laravel/blob/8.1/Dockerfile
But there was a little caveat.
The problem
I was logged in as root when I launched Docker terminal. The main pitfall of this approach is that php artisan generated files have a root owner even on the host machine.
When I checked the Dockerfile, I found this line
RUN usermod -u 1000 www-data
We can't log in as this user because of the no-login directive in /etc/passwd file. Second thing, files in docker have group gid 1000 which doesn't exist...
Probably if we exec artisan commands as the www-data user from the host machine everything would be ok, but I prefer to login into docker and operate from there.
Group www-data had gid 33.
Solution
Solution is to change the www-data group gid, create a new user who has a login possibility, and assign it to the www-data group.
RUN groupmod -g 1000 www-data
RUN useradd -u 1000 -ms /bin/bash -g www-data dockeruser
RUN chown -R dockeruser:www-data /var/www
USER dockeruser
And voila, everything works :)
Top comments (0)