docker exec --user root -it containerName code example Example: docker exec bash root user docker exec -u root -it <container-id> /bin/bash