When I inspect a docker container , what does this path configuration mean and how is this value used?
"Id": "xxx",
"Created": "xxx",
"Path": "orderer"
When I inspect a docker container , what does this path configuration mean and how is this value used?
"Id": "xxx",
"Created": "xxx",
"Path": "orderer"
2
Answers
When you
docker container inspect <something>
, the beginning of the output looks something like:Id
is the container id (you see this in the first column ofdocker container ps
, and you can use it to reference a container instead of using the name)Created
is a timestamp that shows when the container was createdPath
is the primary executable in the container. This is "the thing that is PID 1".Args
are the arguments provided to the executable described byPath
If your container image has an
ENTRYPOINT
,Path
will reflect theENTRYPOINT
script. Otherwise it will reflect the value ofCMD
— either theCMD
entry from your Dockerfile or a command passed in on thedocker run
command line after the image name.Let’s figure this out empirically. See TLDR below for summary.
Suppose that you run the following Python image:
Looking at the top of the
docker inspect
output you’ll see:The
Path
andArgs
fields need to be considered together. The above output indicates that the process launched in the container waspython3
(with no further arguments).Now suppose I have another custom image that has
The corresponding
docker inspect
output is:This tells us that the main command being run in the container is
docker-entrypoint.sh /bin/bash
. The script part of that command resolves to/usr/local/bin/docker-entrypoint.sh
in the container and that script in turn will start a BASH shell when it has the/bin/bash
argument.What about running another common container:
Here the main command is
/docker-entrypoint.sh nginx -g "daemon off;"
.Final example, a
Dockerfile
that ends like this:Here we can see where the
Path
comes from: it’s the first argument toENTRYPOINT
. TheArgs
is populated by either (1) the remaining arguments toENTRYPOINT
or (2) all arguments toCMD
.TLDR
The
Path
andArgs
fields in thedocker inspect
output specify the main process running in the container. ThePath
gives the name of the executable and theArgs
gives any arguments passed to the executable.