Search notes:

docker inspect

docker inspect displays low level information such as information that is added with a Dockerfile LABEL command.
docker inspect [OPTIONS] NAME|ID [NAME|ID…]

Options

-f --format string Format the output using the given Go template
-s --size Display total file sizes if the type is container
--type string Return JSON for specified type

Print (default) cmd and entrypoint

The following cammand includes printf in the format to separate the value for cmd and *entrypoint*` with a new line:
docker inspect -f '{{printf "%s\n%s" .Config.Cmd .Config.Entrypoint}}' env-test

Print environment variables

$ docker inspect --format '{{json .Config.Env}}' container-registry.oracle.com/database/free  | jq
[
  "ORACLE_BASE=/opt/oracle",
  "ORACLE_HOME=/opt/oracle/product/23c/dbhomeFree",
  "INSTALL_FILE_1=http://localhost:8080/23.2.0/oracle-database-free-23c-1.0-1.el8.x86_64.rpm",
  "RUN_FILE=runOracle.sh",
  "PWD_FILE=setPassword.sh",
  "CREATE_DB_FILE=createDB.sh",
  "USER_SCRIPTS_FILE=runUserScripts.sh",
  "CONF_FILE=oracle-free-23c.conf",
  "CHECK_SPACE_FILE=checkSpace.sh",
  "CHECK_DB_FILE=checkDBStatus.sh",
  "SETUP_LINUX_FILE=setupLinuxEnv.sh",
  "CONFIG_TCPS_FILE=configTcps.sh",
  "INSTALL_DIR=/install",
  "ORACLE_DOCKER_INSTALL=true",
  "CHECKPOINT_FILE_EXTN=.created",
  "PREINSTALL_FILE=http://localhost:8080/23.2.0/oracle-database-preinstall-23c-1.0-0.5.el8.x86_64.rpm",
  "PATH=/opt/oracle/product/23c/dbhomeFree/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
  "ENABLE_ARCHIVELOG=false",
  "ORACLE_SID=FREE",
  "ORACLE_PDB=FREEPDB1",
  "ORACLE_PWD=",
  "AUTO_MEM_CALCULATION=false"
]

Get an image's process id

$ docker_id=$(docker ps -f 'name=ora23c' -f 'status=running' -q)
$ docker inspect $docker_id | grep '"Pid"'
            "Pid": 1706,
$ ps p 1706
  PID TTY      STAT   TIME COMMAND
 1706 ?        Ss     0:00 /bin/bash /opt/oracle/container-entrypoint.sh

Get a container's IP address

$ docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $CONTAINER
$ docker inspect $CONTAINER | jq -r ".[0].NetworkSettings.Networks.\"$NETWORKNAME\".IPAddress"

See also

Docker commands

Index