Reputation: 1
I created a RHEL 7 Docker container using the Dockerfile USER instruction to create a rootless user. I can exec into the container, issue the whoami command and I can identify myself as that non-root user. However, I cannot execute any root-equivalent command i.e. yum update because it prompts me for the root password. When I sudo or su - it prompts me for the root password even though I never assigned a password to root.
Why is the system prompting me for a root password if I never created one? So I can elevate my rights and execute priviledge commands?
Can you switch from a rootless user to root in a container that was created with a rootless user?
Upvotes: 0
Views: 1197
Reputation: 311606
Why is the system prompting me for a root password if I never created one? So I can elevate my rights and execute privileged commands?
Because by default the root
account is locked (so it looks like it has a password, but it's not a valid one).
Can you switch from a rootless user to root in a container that was created with a rootless user?
If you've installed and configure sudo
you could become root
in the container using sudo
. However, rather than "switching" to the root
account, it's probably easier to create a root
shell using the -u
argument to docker exec
:
docker exec -u root -it mycontainer -- bash
Upvotes: 2