1

I execute a docker run command as shown below

docker run -it --rm --net=host tensorrtserver_client

When I execute this command, I see that command prompt changes

from

Rajini@server_name

to

root@server_name :/#

Doesn't 'it' in the command above stands for interactive?

Can you let me know what is happening here?

If it's starting the container with image 'tensorrtserver_client', then shouldn't it be entering the container prompt? and show something like container_id :#?

Please find the link to dockerfile and procedure that I followed

https://github.com/NVIDIA/tensorrt-inference-server/blob/master/Dockerfile.client

https://docs.nvidia.com/deeplearning/sdk/tensorrt-inference-server-guide/docs/quickstart.html

The Great
  • 7,215
  • 7
  • 40
  • 128

3 Answers3

2

a) If you use default docker0 network & did not specify --hostname of container, then it behavior like next:

shubuntu1@shubuntu1:~$ docker run -it ubuntu /bin/bash
root@0ad9bd6bfc90:/#

b) If you use default docker0 & specify --hostname of container, it will be like:

shubuntu1@shubuntu1:~$ docker run -it --hostname=abc ubuntu /bin/bash
root@abc:/#

c) If you do not use docker0, use --net=host just as your situation, then it will share the network of host. Then if you did not specify --hostname, it will give an implicit hostname for your container, that is same as your docker host name:

shubuntu1@shubuntu1:~$ docker run -it --net=host ubuntu /bin/bash
root@shubuntu1:/# 

So above c) means you are already in prompt of container.

atline
  • 28,355
  • 16
  • 77
  • 113
2

You got root@server_name :/# because /bin/bash is the default entrypoint of tensorrtserver_client image.

I tried these steps:

  • Ran the tensorrtserver_client container
[node1] (local) root@192.168.0.38 ~/tensorrt-inference-server
$ docker run -it --rm --net=host tensorrtserver_client
root@node1:/workspace#
root@node1:/workspace# ps -ef
UID         PID   PPID  C STIME TTY          TIME CMD
root          1      0  0 05:55 pts/0    00:00:00 /bin/bash
root         12      1  0 05:55 pts/0    00:00:00 ps -ef
root@node1:/workspace# exit
[node1] (local) root@192.168.0.38 ~/tensorrt-inference-server
$
  • Got root@node1:/workspace# Because /workspace is the default working directory as it is set in dockerfile and root is the default user for this image.
  • You also got inside the /bin/bash shell after running the docker run command because /bin/bash is the deafult entrypoint of this image. You can verfiy this by running these commands:
$ docker inspect tensorrtserver_client
[
    {
        "Id": "sha256:90fd86dbcced04a0c585f96debc5a43b5e96bf5adfde5c7f71469d50e51ee3cd",
        "RepoTags": [
            "client:latest"
        ],
        "RepoDigests": [],
        "Parent": "sha256:8594a21faf37dbad5a9a8a2bd0129b26ebb68a6ba07a145824b29a6df90d108b",
        "Comment": "",
        "Created": "2019-06-20T05:06:55.754977279Z",
        "Container": "5b6ba9901c854df63128ead1ec7d33ceab5de0d94713a59d18eda726b03b8c76",
        "ContainerConfig": {
            "Hostname": "5b6ba9901c85",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "PATH=//workspace/install/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                "DEBIAN_FRONTEND=noninteractive",
                "LD_LIBRARY_PATH=/workspace/install/lib:"
            ],
            "Cmd": [
                "/bin/sh",
                "-c",
                "#(nop) ",
                "ENV LD_LIBRARY_PATH=/workspace/install/lib:"
            ],
            "ArgsEscaped": true,
            "Image": "sha256:8594a21faf37dbad5a9a8a2bd0129b26ebb68a6ba07a145824b29a6df90d108b",
            "Volumes": null,
            "WorkingDir": "/workspace",
            "Entrypoint": null,
            "OnBuild": null,
            "Labels": {}
        },
        "DockerVersion": "19.03.0-beta2",
        "Author": "",
        "Config": {
            "Hostname": "",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "PATH=//workspace/install/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                "DEBIAN_FRONTEND=noninteractive",
                "LD_LIBRARY_PATH=/workspace/install/lib:"
            ],
            "Cmd": [
                "/bin/bash"
            ],
            "ArgsEscaped": true,
            "Image": "sha256:8594a21faf37dbad5a9a8a2bd0129b26ebb68a6ba07a145824b29a6df90d108b",
            "Volumes": null,
            "WorkingDir": "/workspace",
            "Entrypoint": null,
            "OnBuild": null,
            "Labels": null
        },
        "Architecture": "amd64",
        "Os": "linux",
        "Size": 2315059023,
        "VirtualSize": 2315059023,
        "GraphDriver": {
            "Data": {
                "LowerDir": "/var/lib/docker/overlay2/403233de5c00747b4a081a690b387da1738e7a00254fc1df54dbd36709971637/diff:/var/lib/docker/overlay2/88e55cce134753ec862d10327241d8b3fcf17c37b367eb6c0cc4a174ad680dff/diff:/var/lib/docker/overlay2/cc4b321d2464be848bf8c2eb641761fecaf0f018b425c4bac56f83b102b4284d/diff:/var/lib/docker/overlay2/6b6a22a0a32f538f30fc10f9aa7ef7ee7473bb60866d8a68e09bce8a6ac0f507/diff:/var/lib/docker/overlay2/85eda7a5ccaab757f25815af57550c0a7b2a542c50cdfa790b42441b261864fc/diff:/var/lib/docker/overlay2/ab4724f8aa278bcb3bdf94d2cfe6c4c4a4005603e46ff61ff81c17d9c92be96c/diff:/var/lib/docker/overlay2/8532010cf9fc575e15f10f62583532a39d080244014b373cee6cc7dab0106678/diff:/var/lib/docker/overlay2/bf05834ad49520b48da6087491d024d60fb4534c5570a9260ef13828c051b179/diff:/var/lib/docker/overlay2/29c653558989a2d853d501034dcf1b58e12d5bcf5b105f84271727b33e157d65/diff:/var/lib/docker/overlay2/578aa342e497269c0f025638ee66ae8a817fc33205ac2765abbc086e74fdde94/diff:/var/lib/docker/overlay2/cbe81f7aac93e8c005537aca3c5212f916717a782ff07e4987440d4733a8c4ec/diff:/var/lib/docker/overlay2/e903955578b6b93db3149c6e4c62af229689100d21f8b8726b8615cee78c214d/diff:/var/lib/docker/overlay2/46e607b2b3826f4021af2c80e41f16868d2c97ed83ea623c103af8a96302d28b/diff:/var/lib/docker/overlay2/580aa8b144b93301e2bbe0f8bb8949e77910eeaf4bb484744a073610ab398faa/diff:/var/lib/docker/overlay2/0b2c6f5f78d999e9084c91b1565e527ebb0e89e9fc80c63528332da8cbd78c83/diff:/var/lib/docker/overlay2/7f8629cdcfc2df52b06a4087c3b97530e472de12ccc01cf9d642800a85ec0253/diff",
                "MergedDir": "/var/lib/docker/overlay2/549a515d33082611583bcb0ad42b7f0d2ed9c8569ef38cecd62df2a0b12705ca/merged",
                "UpperDir": "/var/lib/docker/overlay2/549a515d33082611583bcb0ad42b7f0d2ed9c8569ef38cecd62df2a0b12705ca/diff",
                "WorkDir": "/var/lib/docker/overlay2/549a515d33082611583bcb0ad42b7f0d2ed9c8569ef38cecd62df2a0b12705ca/work"
            },
            "Name": "overlay2"
        },
        "RootFS": {
            "Type": "layers",
            "Layers": [
                "sha256:1ea5a27b0484f2a227275fbb913d281461d9f356134a56002574904c3cfdea04",
                "sha256:24ab7de5faec98f9068e68257ce51c43cb98044a108e3f7f107e60bba3ad2ef4",
                "sha256:10e46f329a252698b52d88487165156ba4a52e5b62e75e10436e4353ae6ca687",
                "sha256:92d3f22d44f3a9ffaa7bbdf9d7ba902a66d39ab8d72e791b60b63a5b813ffa31",
                "sha256:47abeda4e29f00f3889731dcda169734217a18d746c9582281e1868ac9ace405",
                "sha256:8fc379b31a250d7b871cd58226d208b6dee1e8a354087f8e7e4c1bcc96ef534e",
                "sha256:a0c43a55c96bd23d6031e0f7c47ae987253f7d4f95b78b116dd49575541a02b3",
                "sha256:aa3a23d6d3ea279a468307bcb8c0c8f14075783f0280fb4a63b9095de2400783",
                "sha256:525a96836c3ce61202e704d92f05c842a49e39f2e3c5f38f14ba53ea570e24e3",
                "sha256:7d6c0707126d5cf34fde14b7beea34ae44c535b3a3301cdf66904c4f0e03a44d",
                "sha256:d454ca1494271bc0b97298214398db2131c76489227e5aece93a7cd6ba4e5a10",
                "sha256:8d7a3022550d6afc42827dd76ae76fec2f45714244fef59625b743d06d0429e9",
                "sha256:f48bf567fc7abcb6fd201d4cc6e681810a8c2bf4ae86bc0ff05f808cd8d5ee02",
                "sha256:3e2618d9f97998a99d605e264ac282374854e1fa18dcdc92b430794de9edc782",
                "sha256:dc97ef09b5fcc5ae74457629fb8ab45dfc817c9fa9de85243045d14341d88534",
                "sha256:4aa8735a33cf1223b12dbd3e3fd4af6aa9d0f14a17f4273bc7cd04f17288b544",
                "sha256:db091c30373fbc4884cfe21a315df24643c4e8801ed2cb3d7984ecc6be4e181f"
            ]
        },
        "Metadata": {
            "LastTagTime": "2019-06-20T05:06:55.838215092Z"
        }
    }
]
  • In above output you can see the entrypoint for this image is set to null

"Entrypoint": null,

  • So in this case command mentioned in default CMD is used which was /bin/bash in your case. As shown in the output mentioned above.

"Cmd": [

"/bin/bash"

],

  • If you want to override the default CMD specify that while running docker run command like below:
$ docker run -it --rm --net=host client /bin/sh
# ps -ef
UID         PID   PPID  C STIME TTY          TIME CMD
root          1      0  0 05:48 pts/0    00:00:00 /bin/sh
root          7      1  0 05:49 pts/0    00:00:00 ps -ef
#
  • OR override the default entrypoint using --entrypoint option in docker run.
$ docker run -it --rm --net=host --entrypoint /bin/sh client
# ps -ef
UID         PID   PPID  C STIME TTY          TIME CMD
root          1      0  1 05:50 pts/0    00:00:00 /bin/sh
root          6      1  0 05:50 pts/0    00:00:00 ps -ef
#
  • To know more about the difference between CMD and ENTRYPOINT check this out.

Hope this helps, let me know.

Community
  • 1
  • 1
mchawre
  • 10,744
  • 4
  • 35
  • 57
  • If I have to edit files inside the container, what should I do? – The Great Jun 20 '19 at 06:10
  • I mean I have a python file inside the workspace but when I try vim editor to open it, it doesn't work. So, how do I edit the files in container? – The Great Jun 20 '19 at 06:11
  • 1
    Try `docker exec` and then `apt-get -y install vim` and now you can edit the files. – mchawre Jun 20 '19 at 06:16
  • Oh I just typed in docker exec apt-get -y install vim and it worked. Is it okay? – The Great Jun 20 '19 at 06:17
  • 1
    Nope if container is runningin background then you need `docker exec` but in your case you are already inside the container. So `apt-get -y install vim` should be enough. – mchawre Jun 20 '19 at 06:20
  • Hi, one more question. I see in the doc that they have this command "/tmp/client/python/image_client.py -m resnet50_netdef -s INCEPTION images/mug.jpg" but I don't see this folder at all. I understand from the doc that they want us to execute this command if we would like to send request to the tensort server but I don't find this images folder at all in container – The Great Jun 20 '19 at 06:41
  • 1
    I found it at this location `/workspace/src/clients/python/image_client.py` – mchawre Jun 20 '19 at 06:51
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/195247/discussion-between-avles-and-mchawre). – The Great Jun 20 '19 at 06:57
1

From the documentation (docker run --help):

-i, --interactive                    Keep STDIN open even if not attached
-t, --tty                            Allocate a pseudo-TTY

So "-it" in itself doesn't exist but it is short for "-i -t".

docker run starts a container and executes the given command inside that container. The "-it" options only instructs docker to keep the standard in open (show the prompt) if the provided command actually opens it.

Running docker run is like connecting with ssh to a remote host. After you authenticate you see the prompt as it is defined on the remote host. After docker run you see the prompt as it is defined by the operating system inside the container or how it was configured during image build (defined in Dockerfile).

In lame word, if the prompt changes then your command was successful. If it doesn't then you are not inside the container.

Hope this helps

Mihai
  • 9,526
  • 2
  • 18
  • 40