Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run Docker container and watch the logs in one single command

Tags:

docker

Right now, I run the following commands to see the logs of my image:

> docker run <my_image>
4985a657ee273afec4d3b6047a93016e83f36b20bf86429048c306658cf8cb49
> docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED              STATUS              PORTS                                                  NAMES
54ea6e6834dd        hub:latest          "/sbin/my_init"     16 hours ago        Up 16 hours         3003/tcp, 5984/tcp, 8080/tcp, 0.0.0.0:2224->2222/tcp   romantic_curie   
> docker logs -f 54e   

Is there a parameter I can add to see the logs right away? Something like docker run --SOME_PARAMETER

like image 936
JLavoie Avatar asked Nov 18 '25 11:11

JLavoie


1 Answers

use this : docker run XXX && docker logs $(docker ps -lq)

like image 183
ZEE Avatar answered Nov 20 '25 05:11

ZEE