Giter Club home page Giter Club logo

Comments (7)

ijpatricio avatar ijpatricio commented on June 30, 2024 2

@RadeJR
I overlooked this functionality, thank you so much for all the care, explanations, and availability!
I'm seating back again for the afternoon and will dive in, for sure it will solve it, it has everything for it!

@jaydrogers
Oh boy, sorry, totally forgot about Discussions!
I need some vacations!!
I'll make some YouTube content with this, it's so so good!!!

Thank you again, @RadeJR and and @jaydrogers

from docker-php.

RadeJR avatar RadeJR commented on June 30, 2024 1

Hi!
I'm not Jay but I'd like to help by sharing how we solved this problem.
Since these images are now using non-root user by default, you can use 2 scripts to modify UID and GID of the default www-data user.

Dockerfile example:

FROM serversideup/php:beta-8.2-fpm-nginx
USER root

# Save the build arguments as a variable, you can specify whatever uid/gid you would like to use, in your example you can use 1000:1000
ARG USER_ID=1000
ARG GROUP_ID=1000

# Use the build arguments to change the UID 
# and GID of www-data while also changing 
# the file permissions for NGINX
RUN docker-php-serversideup-set-id www-data $USER_ID:$GROUP_ID && \
  \
  # Update the file permissions for our NGINX service to match the new UID/GID
  docker-php-serversideup-set-file-permissions --owner $USER_ID:$GROUP_ID --service nginx

# Drop back to our unprivileged user
USER www-data

This will enable you to run containers as the user you created and allow them to read/write to mounted volumes.
Let me know if you have more questions or if i didnt answer something!

from docker-php.

RadeJR avatar RadeJR commented on June 30, 2024 1

I was sure that there were docs for this exact issue but I didn't manage to find them before posting my previous response.
Here's the link:
https://serversideup.net/open-source/docker-php/docs/guide/understanding-file-permissions

You have an example of Dockerfile and docker-compose.yml that you can use in development.

I hope that these docs solve your problem, but if you need anything else, let me know.

from docker-php.

ijpatricio avatar ijpatricio commented on June 30, 2024

Hey @RadeJR

I definitely forgot there are more people that see this! I'm very welcome to feedback from everyone!!

This sure helps a lot!! I have to try it!

Something I'm missing is, when in local (dev), if the base image has everything I need, should I need to build as well with current uid and gid?

from docker-php.

ijpatricio avatar ijpatricio commented on June 30, 2024

and thank you so so much for feedback @RadeJR

from docker-php.

jaydrogers avatar jaydrogers commented on June 30, 2024

Thanks for chiming in @RadeJR! Yes, using the example above is the way.

Any other questions, @ijpatricio open a discussion and I'd be glad to help!

from docker-php.

sneycampos avatar sneycampos commented on June 30, 2024

Something I'm missing is, when in local (dev), if the base image has everything I need, should I need to build as well with current uid and gid?

Probably yes to solve the problem with sync with volumes. If you use volume in your local environment, the files will be synced and belongs to your host user (1000) but in container this user doesn't exists.

A "dev" image was a nice catch to solve this problem when using in local environment or even in main image, using environment variables, for example:

environments:
    - UID: 1000
    - GID: 1000

from docker-php.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.