Skip to content
This repository was archived by the owner on Oct 26, 2019. It is now read-only.

Conversation

@hacfi
Copy link
Contributor

@hacfi hacfi commented Mar 2, 2015

See http://docs.docker.com/reference/api/docker_remote_api_v1.17/#get-container-stats-based-on-resource-usage

I think if you use $wait = true this will run until the container stops. At some point we could try to return a stream to use the output while it’s streamed.

@ubermuda
Copy link
Contributor

ubermuda commented Mar 3, 2015

"At some point" yes but right now this should be sufficient.

It's missing docs and tests though :)

@hacfi
Copy link
Contributor Author

hacfi commented Mar 5, 2015

@ubermuda Added.

However there is an issue with $wait = true when running the code with PHPUnit.
If I run docker run -t -i --rm ubuntu:precise sleep 10 and open a Symfony controller action containing

    /**
     * @Route("/docker/{containerId}/stats", name="docker_stats")
     */
    public function statsAction($containerId)
    {
        /** @var Docker $docker */
        $docker = $this->get('docker');

        $container = new Container();
        $container->setId($containerId);

        $containerManager = $docker->getContainerManager();
        $stats = $containerManager->stats($container, true);

        return new Response('<html><body><pre>'.var_export($stats, true).'</pre></body></html>');
    }

it works fine and returns with 10 arrays of stats after 10 seconds. But the added testStatsWait test doesn’t stop although docker ps confirms that the container stopped. I currently don’t have a clue why the stream doesn’t stop when running with PHPUnit.

@hacfi
Copy link
Contributor Author

hacfi commented Mar 5, 2015

As we can only run Docker 1.4.1 / Remote API 1.16 on Travis at the moment the tests are skipped.

@hacfi
Copy link
Contributor Author

hacfi commented Apr 15, 2015

With Docker 1.6 on the way I hope we can update soon. The issues with Travis should be fixed now.

@ubermuda
Copy link
Contributor

@hacfi can you rebase this on master if you still want it merged?

@hacfi
Copy link
Contributor Author

hacfi commented Aug 28, 2015

Will do on the weekend..will also make sure the tests run on travis - it worked with my last commit using docker 1.8.1

@joelwurtz
Copy link
Member

closed in #147

@joelwurtz joelwurtz closed this Jan 11, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants