Docker Community Forums

Share and learn in the Docker community.

How to be root inside container

(Flccsw) #1

Hello everybody. I’m trying to become root inside a container and all I can find on the internet and this forum is about how to become non-root.

I asked to a friend about this and he sent me this log of his commands:

$ docker run -t -i geodata/gdal /bin/bash
root@28d68e2d247c:/data# id
uid=0(root) gid=0(root) groups=0(root)

I try the very same command and I get this instead:

$ docker run -t -i geodata/gdal /bin/bash
nobody@59633bc7cb93:/data$ id
uid=65534(nobody) gid=65534(nogroup) groups=65534(nogroup)

Could anybody point me what I’m doing wrong or what should I look in my system?

Thanks in advance.

(Sreenivas Makam) #2

When container is created, we can mention what username to use. Typically, that detail is in Dockerfile. By default, container runs as “root” user. This can be overridden. Most likely, these are 2 different versions of container, 1 with “root” user and another with “nobody” user.

(Flccsw) #3

I don’t see anything related with users in geodata/gdal Dockerfile.

Could it be another reason?

(2i3r) #4

Your problem might has been solved after 9 months, but for record, you might been using an old version of Dockerfile for build, as the maintainer removed USER nobody line from Dockerfile in his c6b2525ead commit.