Franck Dernoncourt
Franck Dernoncourt

Reputation: 83387

Why is Config.User an empty string when I inspect a Docker container?

I pulled and ran the Docker container jcsilva/docker-kaldi-gstreamer-server:

docker pull jcsilva/docker-kaldi-gstreamer-server
docker run -it -p 8080:80 -v /media/kaldi_models:/opt/models jcsilva/docker-kaldi-gstreamer-server:latest /bin/bash

I can see it running:

username@server:~$ docker ps
CONTAINER ID        IMAGE                                          COMMAND                  CREATED             STATUS              PORTS                                                                                                     NAMES
24f598fd5019        jcsilva/docker-kaldi-gstreamer-server:latest   "/bin/bash"              12 hours ago        Up 12 hours         0.0.0.0:8080->80/tcp     

When I inspect it:

username@server:~$ docker inspect 24f598fd501911f32e10884ed3f86547e05a031f0d31324badc40c5fb5ed732a > inspection.json

I see in the inspection.json:

    "Config": {
        "Hostname": "24f598fd5019",
        "Domainname": "",
        "User": "",                       <-- Why is User an empty string?
        "AttachStdin": true,
        "AttachStdout": true,
        "AttachStderr": true,
        "ExposedPorts": {
            "80/tcp": {}
        },

What could explain that Config.User is an empty string?

I use Docker version 18.03.0-ce, build 0520e24 on Ubuntu 16.04.4 LTS (GNU/Linux 4.4.0-119-generic x86_64).

Upvotes: 5

Views: 4876

Answers (2)

Rotem jackoby
Rotem jackoby

Reputation: 22198

As far as I know, docker inspect will show only the configuration that the container started with.

Because of the fact that commands like entrypoint (or any init script) might change the user, those changes will not be reflected on the docker inspect output.

In order to work around this, you can to overwrite the default entrypoint set by the image with
--entrypoint="" and specify a command like whoami or id after it.

In your case:

docker container run --rm --entrypoint "" jcsilva/docker-kaldi-gstreamer-server whoami

You can see that the output for the image you specified is the root user.

Read more about entrypoint "" in here.

Upvotes: 2

Roger Lipscombe
Roger Lipscombe

Reputation: 91895

Because the Dockerfile doesn't have a USER directive, most likely. Why are you expecting it to have one?

Of all of the containers running on my PC right now, only one has a user, and that's grafana, because that's what's in the Dockerfile. It's not the user (me: roger) that launched it.

Upvotes: 3

Related Questions