Refactoring and fixes of /docker API endpoint.

This canges the output of the Docker endpoint to be a map so that it is
more consistent from single to multiple returns. It also refactors
internally how we handle both types of requests.

Without this PR the /docker API endpoint is broken completely so this
change in format has no effect anyways.

These changes are tested by the upcoming integration tests.
I remember seeing one where the `/docker` UI endpoint returned an error if there were no containers. This patch does fix that as well. It shows a page with no subcontainers.