https://stackoverflow.com/questions/56844746/how-to-set-uid-and-gid-in-docker-compose
In Docker-compose.yml
add user (So created volume will be your current user and group, and docker container will be run as specified user and group as well).
// It's a good idea to not use system variable UID and GID as UID is read only and bash will produce an error UID: readonly variable to terminate script execution
// https://serverfault.com/questions/259843/bash-script-error-test-line-5-uid-readonly-variable
..
servuces:
app:
user: "${uID}:${gID}"
.....
volumes:
- ./app:/app
*****
********export GID and UID before docker compose cmd or set in bash_profile so they are available for your session *** man id to see that -u is effective user id and -g is effective group id
export uID="$(id -u)"
export gID="$(id -g)"
:wq!
source .bash_profile or relogin if not working
No comments:
Post a Comment