-
-
Save henrymazza/359907492f482b6a77639d151bd2fd46 to your computer and use it in GitHub Desktop.
Run a command on all docker containers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
if [ $# -eq 0 ]; then | |
echo "No arguments provided" | |
exit 1 | |
fi | |
for container in `docker ps -q`; do | |
# show the name of the container | |
printf '%-40s' $(docker inspect --format='{{.Name}}' $container) | |
# run the command (date in the case) | |
docker exec -it $container $1; | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Like: