I would like to get automate a process where I launch my container, get its id and see the logs, to make sure my application correctly started. Why I do is :

  1. docker run --name my-container
  2. docker ps so I can get the container id
  3. docker logs to see the logs.

I want to automate the last 2 points. I am tired of doing this manually. I see that we can the container id with docker ps -aqf "name=my-container". How to pipe the result of this command to docker logs?

I have tried many things like : docker logs -f < docker ps -aqf "name=my-container" and the error that I have is : the file cdfff3s23r does not exists

Or something like this : docker logs -f | docker ps -aqf "name=my-container"

Any help would be appreciated, thx

  • docker logs -f $(docker ps -aqf "name=my-container") – muru May 6 at 15:33

Browse other questions tagged or ask your own question.