Run Command across all docker containers

There are many a times where I had to run commands across all docker containers. Here is an handy script to do that:

$ cat

for container in `docker ps -q`; do 

  # show the name of the container

  docker inspect –format='{{.Name}}’ $container;

  # run the command (date in the case)

  docker exec -it $container $1;