I’m using dgraziotin/lamp and when i attach to container with “docker exec -it my-container-name /bin/bash” i become inside as root user, and i want to be as regular user, how i can do it, help me, please!
Check the user guide for further info, but what you are looking for is this:
Dockerfile reference for the USER instruction
If a service can run without privileges, use USER to change to a non-root user. Start by creating the user and group in the Dockerfile with something like RUN groupadd -r postgres && useradd -r -g postgres postgres.
Note: Users and groups in an image get a non-deterministic UID/GID in that the “next” UID/GID gets assigned regardless of image rebuilds. So, if it’s critical, you should assign an explicit UID/GID.
You should avoid installing or using sudo since it has unpredictable TTY and signal-forwarding behavior that can cause more problems than it solves. If you absolutely need functionality similar to sudo (e.g., initializing the daemon as root but running it as non-root), you may be able to use “gosu”.
Lastly, to reduce layers and complexity, avoid switching USER back and forth frequently.
In the user guide the line right under ‘USER’ is a link to more info about it.