Container’s logs can be retrieved using the following command:

hakuna logs <container_name>

For example:

hakuna logs some-nginx

This command will retrieve the latest 200 lines of logs of the container.

Additional Parameters

From the hakuna logs --help page:

  • -f, --follow: Continue listing of container’s logs (classic logs follow feature)
  • -t, --timestamp: Print the timestamp of the message in ISO8601 format

Note that the logs aren’t retrieved directly from the host that runs the container, that’s due to the multi-cloud support. Therefore you may notice a few seconds of delay using the -f parameter. For the same reason, the timestamp provided using -t are not 100% accurate, but they could shift around a few seconds.

This has been written just for documentation purposes, logs are retrieved constantly and you should have NOT any issue.

The parameters above could be combined, though it’s not always a good practice, let’s see an example:

hakuna logs -f some-mongodb

Assuming we just started a mongodb container it will retrieve the logs and start following…

2019-12-19T10:02:00.618+0000 I  CONTROL  [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2019-12-19T10:02:00.620+0000 I  CONTROL  [initandlisten] MongoDB starting : pid=1 port=27017 dbpath=/data/db 64-bit host=eda8124825d5
2019-12-19T10:02:00.620+0000 I  CONTROL  [initandlisten] db version v4.2.2

As you can see, a timestamp is already included in MongoDb’s logs, in that case -t option should not be used.

Otherwise, if container’s logs do not include any timestamp but you want it, use -t and hakuna will add a timestamp :-)