Docker Community Forums

Share and learn in the Docker community.

Exactly solution for access root user in docker container

Hi. I want use root user in docker container like such as su or sudo.

But, I can not access this root user in my container.

If I use centos or ubuntu base image, (or only use library base), how to prepare setting for access root user?

please a little hints. thank you.

You’re root by default in most of the library images, e.g.:

$ docker run -ti ubuntu whoami
root

Usually in the image build you install stuff as this user (so you don’t need sudo) and then drop down to a less privileged user for the actual runtime.