6 ms·
Within docker-compose.yml I use services: foo: image: foo/bar:6.9 user: ${UID:-1000}:${UID:-1000} On Linux with Bash it runs with your curre
by professor_v 5y ago
Within docker-compose.yml I use
services:
foo:
image: foo/bar:6.9
user: ${UID:-1000}:${UID:-1000}
On Linux with Bash it runs with your current user and most other platforms it runs with id 1000, which is setup as the default user in the Dockerfile. This is no problem on MacOS or Windows because of the way Docker-Desktop uses VM's.
ZSH or other shells don't necessarily set $UID, so if you're running Linux, not id 1000 and not running Bash you might need a little .env file with `UID=1001` in it to make it work. And then the user is still nameless in the container. This is kind of rare and I only use it for dev containers where most relevant files (and permissions) are bind-mounted from the host, so it hasn't really been a problem in practice.
Remaps would be cleaner but I find it too much work to explain for normal developers just wanting to use a dev container.
- dandarie 5y agoFrom my experience, UID is not always available as to docker-compose.yml because it isn't exported (at least in bash). See more here: https://stackoverflow.com/a/50900530/15428104 https://stackoverflow.com/a/50900530/15428104 $ declare -p UID declare -ir UID="1000" The -x option is missing.
- StavrosK 5y agoThis is excellent, thank you.