You can use:
docker inspect --format "{{json .State.Health }}" <container name> | jq
Output:
{ "Status": "unhealthy", "FailingStreak": 63, "Log": [ { "Start": "2017-03-11T20:49:19.668895201+03:30", "End": "2017-03-11T20:49:19.735722044+03:30", "ExitCode": 1, "Output": "ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''SELECT 1'' at line 1\n"
And find the output section.
To get only output:
docker inspect --format "{{json .State.Health }}" mariadb_db_1 | jq '.Log[].Output'
Feel free to change jq
for any tool you use for json pretty print.
source share