How can I view the logs of a docker container running in the background?

So I had a Jenkins job that was building a Lambda function docker image and testing it. The tests worked locally but some how they were failing when Jenkins was running them.

The Jenkins job didn’t show me the docker image logs so I use this below:

I use this to test the lambda

TEST_RESPONSE=$(curl -XPOST “http://localhost:9000/2015-03-31/functions/function/invocations" -d @”$TEST_FILE”)

Then after catching the response, I had jenkins output the docker logs

docker container logs — details $(docker ps -aqf “ancestor=$image”)

Hope this helps you out.