2 ms·
It certainly is a problem. We want to run local development stacks with Docker, but, since it runs as root, it leaves files into your home directory (database a
by stavros 5y ago
It certainly is a problem. We want to run local development stacks with Docker, but, since it runs as root, it leaves files into your home directory (database and other files mounted from the guest) that are owned by root, so you can never delete them.
It's really bad UX.
- hda111 5y agoRootless Podman does this as well but with the subuid owned files. For instance you run postfix in a container and it has files owned by postfix. You can’t change the files outside of the container. You can make yourself root in the namespace and delete with podman unshare however. But it isn’t optimal from UX perspective either.
- wiredfool 5y agoHome directory, /etc, or /root/.ssh/authorized_keys, depending on what arguments you pass to -v.
- nickjj 5y agoIf you create a user inside of your Dockerfile and switch to that your files will be owned by whoever is assigned to uid:gid 1000:1000 on your dev box if you use a volume mount. This solves the problem in nearly every case because your primary dev box user is almost always going to be 1000:1000. It'll work on native Linux, Windows (WSL) and macOS using Docker Desktop or not. Here's a bunch of complete web app examples of it working: https://github.com/nickjj?tab=repositories&q=docker-*-example https://github.com/nickjj?tab=repositories&q=docker-*-exampl...
- stavros 5y agoOh, good call, I wasn't doing this because 1000 is not always the user uid, but it's almost always, and at worst you'll need root to delete the files, thanks!