DOCKER-285: docker ps improvements

Resolution

Incomplete: The problem is not completely described.
(Resolution Date: 2018-05-22T17:34:44.445Z)

Description

https://docs.docker.com/reference/commandline/cli/#ps

Items to improve on for "docker ps":

1. sort results by container creation time (sdc-docker is currently backwards)
2. show assigned TCP/UDP ports
3. show sizes (we currently show 0 B)
4. support -n argument - to limit output
5. support -l argument - only show latest container (implies -a)
6. support --before and --since - for start/end positioning
7. support -f argument - filter output according to values passed in

Comments

Comment by Bot Bot [X]
Created at 2015-04-10T16:44:33.000Z

sdc-docker commit 928d095 (branch master, by Todd Whiteman)

DOCKER-285 docker ps improvements
  • tested against docker integration-cli


Comment by Todd Whiteman
Created at 2015-04-10T17:04:06.000Z
This commit implemented:
1. sort results by container creation time (sdc-docker is currently backwards)
4. support -n argument - to limit output
5. support -l argument - only show latest container (implies -a)
6. support --before and --since - for start/end positioning
7. support -f argument - filter output according to values passed in

Still not implemented are:
2. show assigned TCP/UDP ports
3. show sizes (we currently show 0 B)


Comment by Angela Fong
Created at 2015-04-14T22:24:20.000Z
Hi Todd - I noticed that when the argument for --before or --since does not match with a valid container ID or Name, it throws an inscrutable error:
FATA0001 An error occurred trying to connect: Get https://165.225.168.25:2376/v1.17/containers/json?before=auto-hadoop96&since=auto-hadoop32: EOF

Initially I thought the system was down but then figured out what the complaint was about. It'll be better if the error message is more explicit about the invalid container name/id. This is minor. If you want me to log a separate ticket for it, I can do that too.

Comment by Todd Whiteman
Created at 2015-04-14T22:40:12.000Z
Updated at 2015-04-15T20:03:00.000Z
Thanks for the report 'docker ps --since fhfhgfhjg' shows this error log:
[2015-04-14T22:37:06.263Z]  INFO: docker/audit/93190 on df364363-716e-4989-884f-736007c52976: handled: 404 (req_id=53c6d8ca-0637-4642-bc7d-7bcda6fc86bc, account=930896af-bf8c-48d4-885c-6573a94b1853, login=admin, route=containerlist, audit=true, remoteAddress=10.88.88.1, remotePort=54234, latency=1043, _audit=true, req.version=*)
    GET /v1.17/containers/json?since=fhfhgfhjg HTTP/1.1
    host: 127.0.0.1:2375
    user-agent: Docker-Client/1.5.0
    accept-encoding: gzip
    --
    HTTP/1.1 404 Not Found
    content-type: text/plain
    content-length: 65
    date: Tue, 14 Apr 2015 22:37:06 GMT
    x-request-id: 53c6d8ca-0637-4642-bc7d-7bcda6fc86bc
    x-response-time: 1042
    
    problem loading containers (53c6d8ca-0637-4642-bc7d-7bcda6fc86bc)
    --
    DockerError: problem loading containers; caused by ResourceNotFoundError: Could not find container with name or id fhfhgfhjg
        at DockerError._DockerBaseError (/opt/smartdc/docker/lib/errors.js:170:15)
        at new DockerError (/opt/smartdc/docker/lib/errors.js:191:22)
        at /opt/smartdc/docker/lib/endpoints/containers.js:94:18
        at /opt/smartdc/docker/lib/backends/sdc/containers.js:1704:21
        at _listVmsCb (/opt/smartdc/docker/lib/backends/sdc/containers.js:1020:9)
        at doneFetching (/opt/smartdc/docker/node_modules/sdc-clients/lib/vmapi.js:205:24)
        at Object.async.whilst (/opt/smartdc/docker/node_modules/sdc-clients/node_modules/async/lib/async.js:562:13)
        at /opt/smartdc/docker/node_modules/sdc-clients/node_modules/async/lib/async.js:558:23
        at /opt/smartdc/docker/node_modules/sdc-clients/lib/vmapi.js:241:28
        at /opt/smartdc/docker/node_modules/sdc-clients/lib/restifyclient.js:112:16
    Caused by: ResourceNotFoundError: Could not find container with name or id fhfhgfhjg
        at /opt/smartdc/docker/lib/backends/sdc/containers.js:1704:30
        at _listVmsCb (/opt/smartdc/docker/lib/backends/sdc/containers.js:1020:9)
        at doneFetching (/opt/smartdc/docker/node_modules/sdc-clients/lib/vmapi.js:205:24)
        at Object.async.whilst (/opt/smartdc/docker/node_modules/sdc-clients/node_modules/async/lib/async.js:562:13)
        at /opt/smartdc/docker/node_modules/sdc-clients/node_modules/async/lib/async.js:558:23
        at /opt/smartdc/docker/node_modules/sdc-clients/lib/vmapi.js:241:28
        at /opt/smartdc/docker/node_modules/sdc-clients/lib/restifyclient.js:112:16
        at parseResponse (/opt/smartdc/docker/node_modules/restify/lib/clients/json_client.js:84:9)
        at IncomingMessage.done (/opt/smartdc/docker/node_modules/restify/lib/clients/string_client.js:151:17)
        at IncomingMessage.g (events.js:180:16)
    --
    req.timers: {
      "handler-0": 87,
      "bunyan": 158,
      "handler-2": 344,
      "parseQueryString": 711,
      "readBody": 224,
      "parseBody": 82,
      "reqAuth": 50265,
      "checkServices": 42,
      "checkApiVersion": 172,
      "containerList": 987803
    }
Uncaught Error: Can't set headers after they are sent.

FROM
ServerResponse.OutgoingMessage.setHeader (http.js:689:11)
ServerResponse.format [as _old_format] (/opt/smartdc/docker/node_modules/restify/lib/response.js:95:10)
ServerResponse._my_format [as format] (/opt/smartdc/docker/lib/docker.js:167:21)
ServerResponse.send (/opt/smartdc/docker/node_modules/restify/lib/response.js:215:24)
/opt/smartdc/docker/lib/endpoints/containers.js:98:13
/opt/smartdc/docker/lib/backends/sdc/containers.js:1790:13
_listVmsCb (/opt/smartdc/docker/lib/backends/sdc/containers.js:1020:9)
doneFetching (/opt/smartdc/docker/node_modules/sdc-clients/lib/vmapi.js:205:24)
Object.async.whilst (/opt/smartdc/docker/node_modules/sdc-clients/node_modules/async/lib/async.js:562:13)
/opt/smartdc/docker/node_modules/sdc-clients/node_modules/async/lib/async.js:558:23
/opt/smartdc/docker/node_modules/sdc-clients/lib/vmapi.js:241:28
/opt/smartdc/docker/node_modules/sdc-clients/lib/restifyclient.js:112:16
parseResponse (/opt/smartdc/docker/node_modules/restify/lib/clients/json_client.js:84:9)
IncomingMessage.done (/opt/smartdc/docker/node_modules/restify/lib/clients/string_client.js:151:17)
IncomingMessage.g (events.js:180:16)
IncomingMessage.emit (events.js:117:20)
_stream_readable.js:943:16
process._tickDomainCallback (node.js:463:13)
[ Apr 14 22:37:06 Stopping because all processes in service exited. ]


Comment by Bot Bot [X]
Created at 2015-04-14T23:00:15.000Z

sdc-docker commit 8c5387b (branch master, by Todd Whiteman)

DOCKER-285: ensure docker ps --since correctly reports invalid container name


Comment by Todd Whiteman
Created at 2015-04-14T23:06:50.000Z
Updated at 2015-04-14T23:07:17.000Z
Two problems noticed and fixed:
1. there was a missing return statement when the missing container error/callback occurred
2. the container list function (docker ps) always re-issued a 'problem loading containers' error whenever an exception was raised - now handles (and shows) docker specific errors


Comment by Bot Bot [X]
Created at 2015-04-15T18:56:26.000Z

sdc-docker commit 1bee7fe (branch master, by Todd Whiteman)

DOCKER-285: add ports to docker ps output


Comment by Todd Whiteman
Created at 2015-04-15T18:59:00.000Z
That leaves this one left:
3. show sizes (we currently show 0 B)

@josh any idea on getting size information for a docker container, or is that not possible (or not accurate enough)?


Comment by Josh Wilsdon
Created at 2015-04-15T19:30:54.000Z
Updated at 2018-05-07T17:50:41.769Z
@todd.whiteman I think we'll have to add something to either vm-agent or cn-agent to start tracking that information if we want to have that work. I'd probably lean toward having vm-agent check every X minutes and write data to a new bucket via vmapi, then add an endpoint like /vms/<uuid>/usage to gather that. Eventually might extend to a point-in-time-snapshot of disk + dram + lwps + other usage... But @andres might have some better ideas too.

Comment by Bot Bot [X]
Created at 2015-05-06T20:05:35.000Z

sdc-docker commit 89e25e0 (branch master, by Todd Whiteman)

DOCKER-285: docker ps should maintain correct ordering
  • most use pipline method instead of parallel method, duh


Comment by Angela Fong
Created at 2018-05-22T17:34:44.460Z
With the reduced investment in docker, we'll not spend time on this improvement. We'll file a new ticket or reopen this if the need comes up again.