docker stats command with JSON output. Which command will correctly show this information?--format option to select the CPU percentage field directly.The docker stats command with --no-stream shows a snapshot of container metrics. Using --format '{{.CPUPerc}}' extracts the CPU usage percentage directly. Option A correctly uses these flags.
docker stats shows the current memory usage of a container?MemUsage shows the current memory used by the container and the total memory available. MemLimit is the maximum memory allowed. CPUPerc is CPU usage, and NetIO is network input/output.
docker stats --no-stream --format '{{json .}}' to extract container names and CPU usage. Which jq command correctly extracts these fields as a JSON array of objects?-s option to read multiple JSON objects as an array.The docker stats command outputs multiple JSON objects, one per line. Using jq -s reads all lines into an array. Then mapping each object to a smaller object with {Name: .Name, CPU: .CPUPerc} produces the desired array.
webapp continuously but only want to see the memory usage percentage updated every 2 seconds. Which command achieves this efficiently?docker stats updates every second unless --no-stream is used.Option D runs docker stats filtered by container name webapp and continuously updates every second (default). To update every 2 seconds, you can use --interval 2 but this flag is not supported by docker stats. So the best is to run it continuously and handle timing externally.
docker stats --no-stream --format '{{json .}}' and pipe it to jq to parse JSON. But jq reports an error: parse error: Invalid numeric literal at line 1, column 10. What is the most likely cause?docker stats --format '{{json .}}' outputs multiple JSON objects, one per line, but not wrapped in an array or separated by commas. jq expects a single JSON document. To parse multiple JSON objects, use jq -s to read them as an array.