docker exec -u root myapp whoami

Category: Docker

docker exec -u root myapp whoami

Execute a command as root inside a container

Runs whoami with the root user regardless of the container's configured user, handy for fixing permissions. -u accepts names or UID:GID pairs like 1000:1000. Only works when the container allows switching.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.